作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/opp into dev

@@ -57,6 +57,9 @@ var errmessge ErrorMap = map[int]string{ @@ -57,6 +57,9 @@ var errmessge ErrorMap = map[int]string{
57 57
58 5510: "评分配置不存在,请联系管理员", 58 5510: "评分配置不存在,请联系管理员",
59 5511: "发现分计算不一致,请重新提交", 59 5511: "发现分计算不一致,请重新提交",
  60 +
  61 + //评论相关
  62 + 5601: "评论不存在",
60 } 63 }
61 64
62 const ( 65 const (
@@ -63,10 +63,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -63,10 +63,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
63 exists bool 63 exists bool
64 chanceFavoirte *models.ChanceFavorite 64 chanceFavoirte *models.ChanceFavorite
65 chance *models.Chance 65 chance *models.Chance
  66 + comment *models.Comment
66 chanceType int 67 chanceType int
67 incre int = 1 68 incre int = 1
68 table string = "comment" 69 table string = "comment"
69 message string = protocol.MessageZanComment 70 message string = protocol.MessageZanComment
  71 + sourceId int64
  72 + userId int64
70 ) 73 )
71 rsp = &protocol.SympathyActionResponse{} 74 rsp = &protocol.SympathyActionResponse{}
72 if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows { 75 if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
@@ -76,11 +79,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc @@ -76,11 +79,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
76 if request.SourceType == protocol.SourceTypeChance { 79 if request.SourceType == protocol.SourceTypeChance {
77 message = protocol.MessageZanChance 80 message = protocol.MessageZanChance
78 if chance, err = models.GetChanceById(request.Id); err != nil { 81 if chance, err = models.GetChanceById(request.Id); err != nil {
79 - log.Error("机会不存在", err) 82 + log.Error(request.Id, "机会不存在", err)
  83 + err = protocol.NewErrWithMessage(5101)
80 return 84 return
81 } 85 }
  86 + sourceId = chance.Id
  87 + userId = chance.UserId
82 chanceType = chance.ChanceTypeId 88 chanceType = chance.ChanceTypeId
83 table = "chance" 89 table = "chance"
  90 + } else if request.SourceType == protocol.SourceTypeComment {
  91 + if comment, err = models.GetCommentById(request.Id); err != nil {
  92 + log.Error(request.Id, "评论不存在", err)
  93 + err = protocol.NewErrWithMessage(5601)
  94 + return
  95 + }
  96 + sourceId = comment.Id
  97 + userId = comment.UserId
  98 + } else {
  99 + log.Error(request.SourceType, "type error")
  100 + err = protocol.NewErrWithMessage(2)
  101 + return
84 } 102 }
85 if chanceFavoirte != nil { 103 if chanceFavoirte != nil {
86 exists = true 104 exists = true
@@ -138,10 +156,10 @@ END: @@ -138,10 +156,10 @@ END:
138 if request.SympathyType == protocol.UnMarkFlag { 156 if request.SympathyType == protocol.UnMarkFlag {
139 incre = -1 157 incre = -1
140 //删除点赞消息 158 //删除点赞消息
141 - agg.DeleteSendedMsg(chance.Id, protocol.SourceTypeChance, chance.UserId, protocol.MsgTypeThumbUp) 159 + agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp)
142 } else { 160 } else {
143 //发送点赞消息 161 //发送点赞消息
144 - agg.SendMsg(chance.UserId, fmt.Sprintf("%v", chance.UserId), chance.CompanyId, chance.Id, 1, message, protocol.MsgTypeThumbUp) 162 + agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, 1, message, protocol.MsgTypeThumbUp)
145 } 163 }
146 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) { 164 if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
147 // 165 //