|
@@ -62,10 +62,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
@@ -62,10 +62,13 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
62
|
exists bool
|
62
|
exists bool
|
63
|
chanceFavoirte *models.ChanceFavorite
|
63
|
chanceFavoirte *models.ChanceFavorite
|
64
|
chance *models.Chance
|
64
|
chance *models.Chance
|
|
|
65
|
+ comment *models.Comment
|
65
|
chanceType int
|
66
|
chanceType int
|
66
|
incre int = 1
|
67
|
incre int = 1
|
67
|
table string = "comment"
|
68
|
table string = "comment"
|
68
|
message string = protocol.MessageZanComment
|
69
|
message string = protocol.MessageZanComment
|
|
|
70
|
+ sourceId int64
|
|
|
71
|
+ userId int64
|
69
|
)
|
72
|
)
|
70
|
rsp = &protocol.SympathyActionResponse{}
|
73
|
rsp = &protocol.SympathyActionResponse{}
|
71
|
if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
|
74
|
if chanceFavoirte, err = models.GetChanceFavorite(header.UserId, header.CompanyId, request.Id, request.SourceType); err != nil && err != orm.ErrNoRows {
|
|
@@ -75,11 +78,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
|
@@ -75,11 +78,26 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc |
75
|
if request.SourceType == protocol.SourceTypeChance {
|
78
|
if request.SourceType == protocol.SourceTypeChance {
|
76
|
message = protocol.MessageZanChance
|
79
|
message = protocol.MessageZanChance
|
77
|
if chance, err = models.GetChanceById(request.Id); err != nil {
|
80
|
if chance, err = models.GetChanceById(request.Id); err != nil {
|
78
|
- log.Error("机会不存在", err)
|
81
|
+ log.Error(request.Id, "机会不存在", err)
|
|
|
82
|
+ err = protocol.NewErrWithMessage(5101)
|
79
|
return
|
83
|
return
|
80
|
}
|
84
|
}
|
|
|
85
|
+ sourceId = chance.Id
|
|
|
86
|
+ userId = chance.UserId
|
81
|
chanceType = chance.ChanceTypeId
|
87
|
chanceType = chance.ChanceTypeId
|
82
|
table = "chance"
|
88
|
table = "chance"
|
|
|
89
|
+ } else if request.SourceType == protocol.SourceTypeComment {
|
|
|
90
|
+ if comment, err = models.GetCommentById(request.Id); err != nil {
|
|
|
91
|
+ log.Error(request.Id, "评论不存在", err)
|
|
|
92
|
+ err = protocol.NewErrWithMessage(5601)
|
|
|
93
|
+ return
|
|
|
94
|
+ }
|
|
|
95
|
+ sourceId = comment.Id
|
|
|
96
|
+ userId = comment.UserId
|
|
|
97
|
+ } else {
|
|
|
98
|
+ log.Error(request.SourceType, "type error")
|
|
|
99
|
+ err = protocol.NewErrWithMessage(2)
|
|
|
100
|
+ return
|
83
|
}
|
101
|
}
|
84
|
if chanceFavoirte != nil {
|
102
|
if chanceFavoirte != nil {
|
85
|
exists = true
|
103
|
exists = true
|
|
@@ -137,10 +155,10 @@ END: |
|
@@ -137,10 +155,10 @@ END: |
137
|
if request.SympathyType == protocol.UnMarkFlag {
|
155
|
if request.SympathyType == protocol.UnMarkFlag {
|
138
|
incre = -1
|
156
|
incre = -1
|
139
|
//删除点赞消息
|
157
|
//删除点赞消息
|
140
|
- agg.DeleteSendedMsg(chance.Id, protocol.SourceTypeChance, chance.UserId, protocol.MsgTypeThumbUp)
|
158
|
+ agg.DeleteSendedMsg(sourceId, request.SourceType, userId, protocol.MsgTypeThumbUp)
|
141
|
} else {
|
159
|
} else {
|
142
|
//发送点赞消息
|
160
|
//发送点赞消息
|
143
|
- agg.SendMsg(chance.UserId, fmt.Sprintf("%v", chance.UserId), chance.CompanyId, chance.Id, 1, message, protocol.MsgTypeThumbUp)
|
161
|
+ agg.SendMsg(userId, fmt.Sprintf("%v", userId), header.CompanyId, request.Id, 1, message, protocol.MsgTypeThumbUp)
|
144
|
}
|
162
|
}
|
145
|
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
|
163
|
if !utils.ExecuteSqlByRoll(true, agg.GetIncrementSql(table, "zan_total", incre, request.Id)) {
|
146
|
//
|
164
|
//
|