...
|
...
|
@@ -63,10 +63,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
|
exists bool
|
|
|
chanceFavoirte *models.ChanceFavorite
|
|
|
chance *models.Chance
|
|
|
comment *models.Comment
|
|
|
chanceType int
|
|
|
incre int = 1
|
|
|
table string = "comment"
|
|
|
message string = protocol.MessageZanComment
|
|
|
sourceId int64
|
|
|
userId int64
|
|
|
)
|
|
|
rsp = &protocol.SympathyActionResponse{}
|
|
|
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 |
|
|
if request.SourceType == protocol.SourceTypeChance {
|
|
|
message = protocol.MessageZanChance
|
|
|
if chance, err = models.GetChanceById(request.Id); err != nil {
|
|
|
log.Error("机会不存在", err)
|
|
|
log.Error(request.Id, "机会不存在", err)
|
|
|
err = protocol.NewErrWithMessage(5101)
|
|
|
return
|
|
|
}
|
|
|
sourceId = chance.Id
|
|
|
userId = chance.UserId
|
|
|
chanceType = chance.ChanceTypeId
|
|
|
table = "chance"
|
|
|
} else if request.SourceType == protocol.SourceTypeComment {
|
|
|
if comment, err = models.GetCommentById(request.Id); err != nil {
|
|
|
log.Error(request.Id, "评论不存在", err)
|
|
|
err = protocol.NewErrWithMessage(5601)
|
|
|
return
|
|
|
}
|
|
|
sourceId = comment.Id
|
|
|
userId = comment.UserId
|
|
|
} else {
|
|
|
log.Error(request.SourceType, "type error")
|
|
|
err = protocol.NewErrWithMessage(2)
|
|
|
return
|
|
|
}
|
|
|
if chanceFavoirte != nil {
|
|
|
exists = true
|
...
|
...
|
@@ -138,10 +156,10 @@ END: |
|
|
if request.SympathyType == protocol.UnMarkFlag {
|
|
|
incre = -1
|
|
|
//删除点赞消息
|
|
|
agg.DeleteSendedMsg(chance.Id, protocol.SourceTypeChance, chance.UserId, protocol.MsgTypeThumbUp)
|
|
|
agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp)
|
|
|
} else {
|
|
|
//发送点赞消息
|
|
|
agg.SendMsg(chance.UserId, fmt.Sprintf("%v", chance.UserId), chance.CompanyId, chance.Id, 1, message, protocol.MsgTypeThumbUp)
|
|
|
agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, 1, message, protocol.MsgTypeThumbUp)
|
|
|
}
|
|
|
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
|
|
|
//
|
...
|
...
|
|