正在显示
11 个修改的文件
包含
361 行增加
和
14 行删除
@@ -72,10 +72,31 @@ func (this *ChanceController) Comments() { | @@ -72,10 +72,31 @@ func (this *ChanceController) Comments() { | ||
72 | return | 72 | return |
73 | } | 73 | } |
74 | header := controllers.GetRequestHeader(this.Ctx) | 74 | header := controllers.GetRequestHeader(this.Ctx) |
75 | - request.SourceType = protocol.SourceTypeChance | 75 | + //request.SourceType = protocol.SourceTypeChance |
76 | msg = protocol.NewReturnResponse(chance.Comments(header, request)) | 76 | msg = protocol.NewReturnResponse(chance.Comments(header, request)) |
77 | } | 77 | } |
78 | 78 | ||
79 | +//Thumbsups 点赞列表 | ||
80 | +// @router /thumbsups [post] | ||
81 | +func (this *ChanceController) Thumbsups() { | ||
82 | + var msg *protocol.ResponseMessage | ||
83 | + defer func() { | ||
84 | + this.Resp(msg) | ||
85 | + }() | ||
86 | + var request *protocol.ThumbsupsRequest | ||
87 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
88 | + log.Error(err) | ||
89 | + msg = protocol.BadRequestParam(1) | ||
90 | + return | ||
91 | + } | ||
92 | + if b, m := this.Valid(request); !b { | ||
93 | + msg = m | ||
94 | + return | ||
95 | + } | ||
96 | + header := controllers.GetRequestHeader(this.Ctx) | ||
97 | + msg = protocol.NewReturnResponse(chance.Thumbsups(header, request)) | ||
98 | +} | ||
99 | + | ||
79 | //Favorite | 100 | //Favorite |
80 | // @router /favorite [post] | 101 | // @router /favorite [post] |
81 | func (this *ChanceController) Favorite() { | 102 | func (this *ChanceController) Favorite() { |
@@ -200,3 +200,45 @@ func (this *MessageController) MsgChanceSubmit() { | @@ -200,3 +200,45 @@ func (this *MessageController) MsgChanceSubmit() { | ||
200 | header := controllers.GetRequestHeader(this.Ctx) | 200 | header := controllers.GetRequestHeader(this.Ctx) |
201 | msg = protocol.NewReturnResponse(message.MsgChanceSubmit(header, request)) | 201 | msg = protocol.NewReturnResponse(message.MsgChanceSubmit(header, request)) |
202 | } | 202 | } |
203 | + | ||
204 | +//MsgChanceComment 消息中心-互动消息.评论 | ||
205 | +//@router /msgChanceComment [post] | ||
206 | +func (this *MessageController) MsgChanceComment() { | ||
207 | + var msg *protocol.ResponseMessage | ||
208 | + defer func() { | ||
209 | + this.Resp(msg) | ||
210 | + }() | ||
211 | + var request *protocol.MsgChanceCommentRequest | ||
212 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
213 | + log.Error(err) | ||
214 | + msg = protocol.BadRequestParam(1) | ||
215 | + return | ||
216 | + } | ||
217 | + if b, m := this.Valid(request); !b { | ||
218 | + msg = m | ||
219 | + return | ||
220 | + } | ||
221 | + header := controllers.GetRequestHeader(this.Ctx) | ||
222 | + msg = protocol.NewReturnResponse(message.MsgChanceComment(header, request)) | ||
223 | +} | ||
224 | + | ||
225 | +//MsgChanceThumbUp 消息中心-互动消息.点赞 | ||
226 | +//@router /msgChanceThumbUp [post] | ||
227 | +func (this *MessageController) MsgChanceThumbUp() { | ||
228 | + var msg *protocol.ResponseMessage | ||
229 | + defer func() { | ||
230 | + this.Resp(msg) | ||
231 | + }() | ||
232 | + var request *protocol.MsgChanceThumbUpRequest | ||
233 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
234 | + log.Error(err) | ||
235 | + msg = protocol.BadRequestParam(1) | ||
236 | + return | ||
237 | + } | ||
238 | + if b, m := this.Valid(request); !b { | ||
239 | + msg = m | ||
240 | + return | ||
241 | + } | ||
242 | + header := controllers.GetRequestHeader(this.Ctx) | ||
243 | + msg = protocol.NewReturnResponse(message.MsgChanceThumbUp(header, request)) | ||
244 | +} |
@@ -81,12 +81,12 @@ func DeleteChanceFavorite(id int64) (err error) { | @@ -81,12 +81,12 @@ func DeleteChanceFavorite(id int64) (err error) { | ||
81 | 81 | ||
82 | //按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数 | 82 | //按1.用户id 2.公司id 3.标记类型 4.机会类型编号 5.最后编号 6.页数 |
83 | //获取用户点赞收藏机会 | 83 | //获取用户点赞收藏机会 |
84 | -func GetChanceFavorites(userId, companyId int64, markFlag, chanceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { | 84 | +func GetChanceFavorites(userId, companyId int64, markFlag, sourceType int, lastId int64, pageSize int) (v []*ChanceFavorite, total int, err error) { |
85 | sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") | 85 | sql := mybeego.NewSqlExutor().Table("chance_favorite").Order("create_at desc") |
86 | sql.Where(fmt.Sprintf("user_id=%d", userId)) | 86 | sql.Where(fmt.Sprintf("user_id=%d", userId)) |
87 | sql.Where(fmt.Sprintf("company_id=%d", companyId)) | 87 | sql.Where(fmt.Sprintf("company_id=%d", companyId)) |
88 | - if chanceType > 0 { | ||
89 | - sql.Where(fmt.Sprintf("chance_type=%d", chanceType)) | 88 | + if sourceType > 0 { |
89 | + sql.Where(fmt.Sprintf("source_type=%d", sourceType)) | ||
90 | } | 90 | } |
91 | if markFlag > 0 { | 91 | if markFlag > 0 { |
92 | sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag)) | 92 | sql.Where(fmt.Sprintf("mark_flag&%d>0", markFlag)) |
@@ -199,3 +199,29 @@ from user_msg where receive_user_id=? and source_type=1 and msg_type=? ` | @@ -199,3 +199,29 @@ from user_msg where receive_user_id=? and source_type=1 and msg_type=? ` | ||
199 | } | 199 | } |
200 | return | 200 | return |
201 | } | 201 | } |
202 | + | ||
203 | +//获取机会评论消息 | ||
204 | +func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) { | ||
205 | + sql := `select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id from ( | ||
206 | +select a.*,b.images,b.speechs,b.videos from ( | ||
207 | +select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status from ( | ||
208 | +select id,message content,source_type,source_id,create_at comment_time from user_msg | ||
209 | +where receive_user_id =? and (?=0 or id>?) and msg_type=? | ||
210 | +)a left outer join chance b on a.source_id = b.id and source_type=1 | ||
211 | +)a left outer join chance_data b on a.source_id = b.chance_id and source_type = 1 | ||
212 | +)a left outer join comment b on a.source_id = b.id and a.source_type=2 | ||
213 | +order by create_at desc | ||
214 | +LIMIT ?` | ||
215 | + | ||
216 | + sqlCount := `select count(0) | ||
217 | +from user_msg where receive_user_id=? and source_type=1 and msg_type=? ` | ||
218 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil { | ||
219 | + return | ||
220 | + } | ||
221 | + if v != nil { | ||
222 | + if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, msgType, pageSize); err != nil { | ||
223 | + return | ||
224 | + } | ||
225 | + } | ||
226 | + return | ||
227 | +} |
@@ -308,10 +308,6 @@ type ChanceCommentItemOrm struct { | @@ -308,10 +308,6 @@ type ChanceCommentItemOrm struct { | ||
308 | Voices string `orm:"column(speechs)"` | 308 | Voices string `orm:"column(speechs)"` |
309 | Videos string `orm:"column(videos)"` | 309 | Videos string `orm:"column(videos)"` |
310 | 310 | ||
311 | - //ApproveData string `json:"approveData"` //审核数据 | ||
312 | - //TemplateId int `orm:"column(audit_template_id)"` | ||
313 | - //ChanceTypeId int `orm:"column(chance_type_id)"` | ||
314 | - | ||
315 | CommentTotal int `orm:"column(comment_total)"` | 311 | CommentTotal int `orm:"column(comment_total)"` |
316 | ZanTotal int `orm:"column(zan_total)"` | 312 | ZanTotal int `orm:"column(zan_total)"` |
317 | ViewTotal int `orm:"column(view_total)"` | 313 | ViewTotal int `orm:"column(view_total)"` |
@@ -425,6 +421,20 @@ type Form struct { | @@ -425,6 +421,20 @@ type Form struct { | ||
425 | Required int8 `json:"required"` | 421 | Required int8 `json:"required"` |
426 | } | 422 | } |
427 | 423 | ||
424 | +//清楚未填写的表单数据 | ||
425 | +func ClearEmptyForm(inputFormList []*Form) (FormList []*Form) { | ||
426 | + if len(inputFormList) == 0 { | ||
427 | + return | ||
428 | + } | ||
429 | + for i := range inputFormList { | ||
430 | + item := inputFormList[i] | ||
431 | + if len(item.Value) > 0 { | ||
432 | + FormList = append(FormList, item) | ||
433 | + } | ||
434 | + } | ||
435 | + return | ||
436 | +} | ||
437 | + | ||
428 | //语音 | 438 | //语音 |
429 | type Speech struct { | 439 | type Speech struct { |
430 | Path string `json:"path"` | 440 | Path string `json:"path"` |
@@ -507,8 +517,9 @@ type CollectData struct { | @@ -507,8 +517,9 @@ type CollectData struct { | ||
507 | 517 | ||
508 | //点赞数据 | 518 | //点赞数据 |
509 | type ThumbUpData struct { | 519 | type ThumbUpData struct { |
510 | - Id int64 `json:"id"` | ||
511 | - ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间 | 520 | + Id int64 `json:"id"` |
521 | + Content string `json:"content"` //点赞内容 | ||
522 | + ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间 | ||
512 | } | 523 | } |
513 | 524 | ||
514 | //评论内容 | 525 | //评论内容 |
@@ -39,13 +39,25 @@ type CommentsRequest struct { | @@ -39,13 +39,25 @@ type CommentsRequest struct { | ||
39 | LastId int64 `json:"lastId"` | 39 | LastId int64 `json:"lastId"` |
40 | PageSize int `json:"pageSize" valid:"Required"` | 40 | PageSize int `json:"pageSize" valid:"Required"` |
41 | SourceId int64 `json:"id" valid:"Required"` | 41 | SourceId int64 `json:"id" valid:"Required"` |
42 | - SourceType int | 42 | + SourceType int `json:"sourceType" valid:"Required"` //1:机会 2:评论 |
43 | } | 43 | } |
44 | type CommentsResponse struct { | 44 | type CommentsResponse struct { |
45 | Comments []*Comments `json:"comments"` | 45 | Comments []*Comments `json:"comments"` |
46 | Total int `json:"total"` | 46 | Total int `json:"total"` |
47 | } | 47 | } |
48 | 48 | ||
49 | +/*Thumbsups 点赞列表*/ | ||
50 | +type ThumbsupsRequest struct { | ||
51 | + LastId int64 `json:"lastId"` | ||
52 | + PageSize int `json:"pageSize" valid:"Required"` | ||
53 | + SourceId int64 `json:"id" valid:"Required"` | ||
54 | + SourceType int `json:"sourceType" valid:"Required"` //1:机会 2:评论 | ||
55 | +} | ||
56 | +type ThumbsupsResponse struct { | ||
57 | + Thumbups []*Thumbups `json:"thumbups"` | ||
58 | + Total int `json:"total"` | ||
59 | +} | ||
60 | + | ||
49 | /*评论列表*/ | 61 | /*评论列表*/ |
50 | type Comments struct { | 62 | type Comments struct { |
51 | Id int64 `json:"id"` | 63 | Id int64 `json:"id"` |
@@ -59,6 +71,12 @@ type Comments struct { | @@ -59,6 +71,12 @@ type Comments struct { | ||
59 | IsZan int `json:"isThumbsUp"` //0:未点赞 1:点赞 | 71 | IsZan int `json:"isThumbsUp"` //0:未点赞 1:点赞 |
60 | } | 72 | } |
61 | 73 | ||
74 | +type Thumbups struct { | ||
75 | + Id int64 `json:"id"` | ||
76 | + CreateTime int64 `json:"createTime"` | ||
77 | + Provider *BaseUserInfo `json:"provider"` | ||
78 | +} | ||
79 | + | ||
62 | /*CommentDetailsMulti */ | 80 | /*CommentDetailsMulti */ |
63 | type CommentDetailsMultiRequest struct { | 81 | type CommentDetailsMultiRequest struct { |
64 | SourceId int64 `json:"cid"` | 82 | SourceId int64 `json:"cid"` |
@@ -42,6 +42,7 @@ var errmessge ErrorMap = map[int]string{ | @@ -42,6 +42,7 @@ var errmessge ErrorMap = map[int]string{ | ||
42 | 5203: "审批服务器操作失败", | 42 | 5203: "审批服务器操作失败", |
43 | 5204: "评分或者公开状态不能为空", | 43 | 5204: "评分或者公开状态不能为空", |
44 | 5205: "机会未审核通过,不能修改评分或者公开状态", | 44 | 5205: "机会未审核通过,不能修改评分或者公开状态", |
45 | + 5206: "未找到审批节点或者无权限", | ||
45 | 46 | ||
46 | //模板相关 | 47 | //模板相关 |
47 | 5301: "机会模板不存在", | 48 | 5301: "机会模板不存在", |
@@ -223,6 +224,26 @@ type MsgChanceSubmitResponse struct { | @@ -223,6 +224,26 @@ type MsgChanceSubmitResponse struct { | ||
223 | Total int `json:"total"` | 224 | Total int `json:"total"` |
224 | } | 225 | } |
225 | 226 | ||
227 | +/*MsgChanceComment 消息中心-互动消息.评论*/ | ||
228 | +type MsgChanceCommentRequest struct { | ||
229 | + LastId int64 `json:"lastId"` | ||
230 | + PageSize int `json:"pageSize" valid:"Required"` | ||
231 | +} | ||
232 | +type MsgChanceCommentResponse struct { | ||
233 | + List []CommonListItem `json:"list"` | ||
234 | + Total int `json:"total"` | ||
235 | +} | ||
236 | + | ||
237 | +/*MsgChanceThumbUp 息中心-互动消息.点赞*/ | ||
238 | +type MsgChanceThumbUpRequest struct { | ||
239 | + LastId int64 `json:"lastId"` | ||
240 | + PageSize int `json:"pageSize" valid:"Required"` | ||
241 | +} | ||
242 | +type MsgChanceThumbUpResponse struct { | ||
243 | + List []CommonListItem `json:"list"` | ||
244 | + Total int `json:"total"` | ||
245 | +} | ||
246 | + | ||
226 | //我的审核机会列表 | 247 | //我的审核机会列表 |
227 | type MsgChanceApproveItemOrm struct { | 248 | type MsgChanceApproveItemOrm struct { |
228 | ChanceUserId int64 `orm:"column(chance_user_id)"` | 249 | ChanceUserId int64 `orm:"column(chance_user_id)"` |
@@ -247,6 +247,14 @@ func init() { | @@ -247,6 +247,14 @@ func init() { | ||
247 | MethodParams: param.Make(), | 247 | MethodParams: param.Make(), |
248 | Params: nil}) | 248 | Params: nil}) |
249 | 249 | ||
250 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
251 | + beego.ControllerComments{ | ||
252 | + Method: "Thumbsups", | ||
253 | + Router: `/thumbsups`, | ||
254 | + AllowHTTPMethods: []string{"post"}, | ||
255 | + MethodParams: param.Make(), | ||
256 | + Params: nil}) | ||
257 | + | ||
250 | beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"], | 258 | beego.GlobalControllerRouter["opp/controllers/v1:CommendController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:CommendController"], |
251 | beego.ControllerComments{ | 259 | beego.ControllerComments{ |
252 | Method: "Company", | 260 | Method: "Company", |
@@ -321,6 +329,14 @@ func init() { | @@ -321,6 +329,14 @@ func init() { | ||
321 | 329 | ||
322 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | 330 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], |
323 | beego.ControllerComments{ | 331 | beego.ControllerComments{ |
332 | + Method: "MsgChanceComment", | ||
333 | + Router: `/msgChanceComment`, | ||
334 | + AllowHTTPMethods: []string{"post"}, | ||
335 | + MethodParams: param.Make(), | ||
336 | + Params: nil}) | ||
337 | + | ||
338 | + beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | ||
339 | + beego.ControllerComments{ | ||
324 | Method: "MsgChanceSubmit", | 340 | Method: "MsgChanceSubmit", |
325 | Router: `/msgChanceSubmit`, | 341 | Router: `/msgChanceSubmit`, |
326 | AllowHTTPMethods: []string{"post"}, | 342 | AllowHTTPMethods: []string{"post"}, |
@@ -329,6 +345,14 @@ func init() { | @@ -329,6 +345,14 @@ func init() { | ||
329 | 345 | ||
330 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | 346 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], |
331 | beego.ControllerComments{ | 347 | beego.ControllerComments{ |
348 | + Method: "MsgChanceThumbUp", | ||
349 | + Router: `/msgChanceThumbUp`, | ||
350 | + AllowHTTPMethods: []string{"post"}, | ||
351 | + MethodParams: param.Make(), | ||
352 | + Params: nil}) | ||
353 | + | ||
354 | + beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | ||
355 | + beego.ControllerComments{ | ||
332 | Method: "MsgCompanyNotice", | 356 | Method: "MsgCompanyNotice", |
333 | Router: `/msgCompanyNotice`, | 357 | Router: `/msgCompanyNotice`, |
334 | AllowHTTPMethods: []string{"post"}, | 358 | AllowHTTPMethods: []string{"post"}, |
@@ -298,7 +298,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -298,7 +298,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
298 | } | 298 | } |
299 | if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil { | 299 | if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil { |
300 | log.Error(request.ProcessId, header.UserId, err) | 300 | log.Error(request.ProcessId, header.UserId, err) |
301 | - err = protocol.NewErrWithMessage(5202) | 301 | + err = protocol.NewErrWithMessage(5206) |
302 | return | 302 | return |
303 | } | 303 | } |
304 | if chance.ReviewStatus != protocol.ReviewStatusAuditging { | 304 | if chance.ReviewStatus != protocol.ReviewStatusAuditging { |
@@ -2,6 +2,7 @@ package chance | @@ -2,6 +2,7 @@ package chance | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/astaxie/beego/orm" | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" | 6 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen" |
6 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
7 | "opp/internal/utils" | 8 | "opp/internal/utils" |
@@ -19,6 +20,8 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | @@ -19,6 +20,8 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | ||
19 | chance *models.Chance | 20 | chance *models.Chance |
20 | updateTable interface{} | 21 | updateTable interface{} |
21 | updateMap = make(map[string]interface{}) | 22 | updateMap = make(map[string]interface{}) |
23 | + recevierId int64 | ||
24 | + sourceId int64 | ||
22 | ) | 25 | ) |
23 | switch request.SourceType { | 26 | switch request.SourceType { |
24 | case protocol.SourceTypeChance: | 27 | case protocol.SourceTypeChance: |
@@ -28,15 +31,22 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | @@ -28,15 +31,22 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | ||
28 | } | 31 | } |
29 | updateTable = chance | 32 | updateTable = chance |
30 | updateMap["CommentTotal"] = chance.CommentTotal + 1 | 33 | updateMap["CommentTotal"] = chance.CommentTotal + 1 |
34 | + recevierId = chance.UserId | ||
35 | + sourceId = chance.Id | ||
36 | + break | ||
31 | case protocol.SourceTypeComment: | 37 | case protocol.SourceTypeComment: |
32 | if comment, err = models.GetCommentById(request.Id); err != nil { | 38 | if comment, err = models.GetCommentById(request.Id); err != nil { |
33 | log.Error(err) | 39 | log.Error(err) |
34 | return | 40 | return |
35 | } | 41 | } |
36 | updateTable = comment | 42 | updateTable = comment |
43 | + recevierId = comment.UserId | ||
44 | + sourceId = comment.Id | ||
37 | updateMap["CommentTotal"] = comment.CommentTotal + 1 | 45 | updateMap["CommentTotal"] = comment.CommentTotal + 1 |
46 | + break | ||
38 | default: | 47 | default: |
39 | err = fmt.Errorf("unknow source_type:%v", request.SourceType) | 48 | err = fmt.Errorf("unknow source_type:%v", request.SourceType) |
49 | + return | ||
40 | } | 50 | } |
41 | newComment := &models.Comment{ | 51 | newComment := &models.Comment{ |
42 | Id: idgen.Next(), | 52 | Id: idgen.Next(), |
@@ -46,8 +56,11 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | @@ -46,8 +56,11 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | ||
46 | CreateAt: time.Now(), | 56 | CreateAt: time.Now(), |
47 | SourceId: request.Id, | 57 | SourceId: request.Id, |
48 | } | 58 | } |
49 | - if _, err = models.AddComment(newComment); err != nil { | 59 | + orm := orm.NewOrm() |
60 | + orm.Begin() | ||
61 | + if _, err = orm.Insert(newComment); err != nil { | ||
50 | log.Error(err) | 62 | log.Error(err) |
63 | + orm.Rollback() | ||
51 | return | 64 | return |
52 | } | 65 | } |
53 | if baseUserInfo, err = agg.GetUserBaseInfo(header.Uid, header.CompanyId); err != nil { | 66 | if baseUserInfo, err = agg.GetUserBaseInfo(header.Uid, header.CompanyId); err != nil { |
@@ -55,8 +68,18 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | @@ -55,8 +68,18 @@ func IComment(header *protocol.RequestHeader, request *protocol.ICommentRequest) | ||
55 | return | 68 | return |
56 | } | 69 | } |
57 | if updateTable != nil { | 70 | if updateTable != nil { |
58 | - utils.UpdateTableByMap(updateTable, updateMap) | 71 | + if err = utils.UpdateTableByMapWithOrmer(orm, updateTable, updateMap); err != nil { |
72 | + log.Error(err) | ||
73 | + orm.Rollback() | ||
74 | + return | ||
75 | + } | ||
76 | + } | ||
77 | + if err = agg.SendMsg(recevierId, "", header.CompanyId, sourceId, request.SourceType, request.Content, protocol.MsgTypeComment); err != nil { | ||
78 | + log.Error(err) | ||
79 | + orm.Rollback() | ||
80 | + return | ||
59 | } | 81 | } |
82 | + orm.Commit() | ||
60 | rsp = &protocol.ICommentResponse{ | 83 | rsp = &protocol.ICommentResponse{ |
61 | Id: newComment.Id, | 84 | Id: newComment.Id, |
62 | Content: newComment.Content, | 85 | Content: newComment.Content, |
@@ -141,6 +164,39 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) | @@ -141,6 +164,39 @@ func Comments(header *protocol.RequestHeader, request *protocol.CommentsRequest) | ||
141 | return | 164 | return |
142 | } | 165 | } |
143 | 166 | ||
167 | +//点赞列表 | ||
168 | +func Thumbsups(header *protocol.RequestHeader, request *protocol.ThumbsupsRequest) (rsp *protocol.ThumbsupsResponse, err error) { | ||
169 | + var ( | ||
170 | + favorites []*models.ChanceFavorite | ||
171 | + total int | ||
172 | + baseUserInfo *protocol.BaseUserInfo | ||
173 | + ) | ||
174 | + rsp = &protocol.ThumbsupsResponse{} | ||
175 | + if favorites, total, err = models.GetChanceFavorites(header.UserId, header.CompanyId, protocol.MarkFlagZan, request.SourceType, request.LastId, request.PageSize); err != nil { | ||
176 | + if err == orm.ErrNoRows { | ||
177 | + err = nil | ||
178 | + return | ||
179 | + } | ||
180 | + return | ||
181 | + } | ||
182 | + for i := range favorites { | ||
183 | + f := favorites[i] | ||
184 | + if baseUserInfo, err = agg.GetUserBaseInfo(f.UserId, header.CompanyId); err != nil { | ||
185 | + log.Error(err) | ||
186 | + //return | ||
187 | + continue | ||
188 | + } | ||
189 | + item := &protocol.Thumbups{ | ||
190 | + Id: f.Id, | ||
191 | + Provider: baseUserInfo, | ||
192 | + CreateTime: f.CreateAt.Unix() * 1000, | ||
193 | + } | ||
194 | + rsp.Thumbups = append(rsp.Thumbups, item) | ||
195 | + } | ||
196 | + rsp.Total = total | ||
197 | + return | ||
198 | +} | ||
199 | + | ||
144 | //评论详情-不带地下评论 | 200 | //评论详情-不带地下评论 |
145 | func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.CommentDetailsSingleRequest) (rsp *protocol.CommentDetailsSingleResponse, err error) { | 201 | func CommentDetailsSingle(header *protocol.RequestHeader, request *protocol.CommentDetailsSingleRequest) (rsp *protocol.CommentDetailsSingleResponse, err error) { |
146 | var ( | 202 | var ( |
@@ -311,6 +311,134 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | @@ -311,6 +311,134 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance | ||
311 | return | 311 | return |
312 | } | 312 | } |
313 | 313 | ||
314 | +// 消息中心-互动消息.评论 | ||
315 | +func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanceCommentRequest) (rsp *protocol.MsgChanceCommentResponse, err error) { | ||
316 | + var ( | ||
317 | + myChances []protocol.ChanceCommentItemOrm | ||
318 | + total int | ||
319 | + provider *protocol.BaseUserInfo | ||
320 | + ) | ||
321 | + if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeComment, &myChances); err != nil { | ||
322 | + if err == orm.ErrNoRows { | ||
323 | + err = nil | ||
324 | + return | ||
325 | + } | ||
326 | + log.Error(err) | ||
327 | + return | ||
328 | + } | ||
329 | + rsp = &protocol.MsgChanceCommentResponse{Total: total} | ||
330 | + for i := 0; i < len(myChances); i++ { | ||
331 | + chance := myChances[i] | ||
332 | + commItem := protocol.CommonListItem{} | ||
333 | + if chance.SourceType == protocol.SourceTypeChance { | ||
334 | + commItem.ReviewStatus = chance.ReviewStatus | ||
335 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
336 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
337 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
338 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
339 | + } else { | ||
340 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
341 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
342 | + log.Error(err) | ||
343 | + //return | ||
344 | + } else { | ||
345 | + item := protocol.ChanceItem{ | ||
346 | + Id: chance.SourceId, | ||
347 | + Provider: provider, | ||
348 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
349 | + } | ||
350 | + utils.JsonUnmarshal(chance.SourceContent, &item.FormList) | ||
351 | + item.FormList = protocol.ClearEmptyForm(item.FormList) | ||
352 | + utils.JsonUnmarshal(chance.Images, &item.Pictures) | ||
353 | + utils.JsonUnmarshal(chance.Voices, &item.Speechs) | ||
354 | + utils.JsonUnmarshal(chance.Videos, &item.Videos) | ||
355 | + commItem.Chance = item | ||
356 | + } | ||
357 | + } | ||
358 | + commItem.ReviewStatus = chance.ReviewStatus | ||
359 | + } | ||
360 | + if chance.SourceType == protocol.SourceTypeComment { | ||
361 | + commItem.CommentedData = protocol.CommentData{ | ||
362 | + Id: chance.SourceId, | ||
363 | + Content: chance.CommentedContent, | ||
364 | + CommentTime: chance.CommentedTime.Unix() * 1000, | ||
365 | + } | ||
366 | + } | ||
367 | + commItem.CommentData = protocol.CommentData{ | ||
368 | + Id: chance.CommentId, | ||
369 | + CommentTime: chance.CommentTime.Unix() * 1000, | ||
370 | + Content: chance.CommentContent, | ||
371 | + } | ||
372 | + commItem.SourceType = chance.SourceType | ||
373 | + rsp.List = append(rsp.List, commItem) | ||
374 | + } | ||
375 | + return | ||
376 | +} | ||
377 | + | ||
378 | +//消息中心-互动消息.点赞 | ||
379 | +func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanceThumbUpRequest) (rsp *protocol.MsgChanceThumbUpResponse, err error) { | ||
380 | + var ( | ||
381 | + myChances []protocol.ChanceCommentItemOrm | ||
382 | + total int | ||
383 | + provider *protocol.BaseUserInfo | ||
384 | + ) | ||
385 | + if total, err = models.GetChanceCommentMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeThumbUp, &myChances); err != nil { | ||
386 | + if err == orm.ErrNoRows { | ||
387 | + err = nil | ||
388 | + return | ||
389 | + } | ||
390 | + log.Error(err) | ||
391 | + return | ||
392 | + } | ||
393 | + rsp = &protocol.MsgChanceThumbUpResponse{Total: total} | ||
394 | + for i := 0; i < len(myChances); i++ { | ||
395 | + chance := myChances[i] | ||
396 | + commItem := protocol.CommonListItem{} | ||
397 | + if chance.SourceType == protocol.SourceTypeChance { | ||
398 | + commItem.ReviewStatus = chance.ReviewStatus | ||
399 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
400 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
401 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
402 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
403 | + } else { | ||
404 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
405 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
406 | + log.Error(err) | ||
407 | + //return | ||
408 | + } else { | ||
409 | + item := protocol.ChanceItem{ | ||
410 | + Id: chance.SourceId, | ||
411 | + Provider: provider, | ||
412 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
413 | + } | ||
414 | + utils.JsonUnmarshal(chance.SourceContent, &item.FormList) | ||
415 | + item.FormList = protocol.ClearEmptyForm(item.FormList) | ||
416 | + utils.JsonUnmarshal(chance.Images, &item.Pictures) | ||
417 | + utils.JsonUnmarshal(chance.Voices, &item.Speechs) | ||
418 | + utils.JsonUnmarshal(chance.Videos, &item.Videos) | ||
419 | + commItem.Chance = item | ||
420 | + } | ||
421 | + } | ||
422 | + commItem.ReviewStatus = chance.ReviewStatus | ||
423 | + } | ||
424 | + if chance.SourceType == protocol.SourceTypeComment { | ||
425 | + commItem.CommentedData = protocol.CommentData{ | ||
426 | + Id: chance.SourceId, | ||
427 | + Content: chance.CommentedContent, | ||
428 | + CommentTime: chance.CommentedTime.Unix() * 1000, | ||
429 | + } | ||
430 | + } | ||
431 | + commItem.ThumbUpData = protocol.ThumbUpData{ | ||
432 | + Id: chance.CommentId, | ||
433 | + ThumbUpTime: chance.CommentTime.Unix() * 1000, | ||
434 | + Content: chance.CommentContent, | ||
435 | + } | ||
436 | + commItem.SourceType = chance.SourceType | ||
437 | + rsp.List = append(rsp.List, commItem) | ||
438 | + } | ||
439 | + return | ||
440 | +} | ||
441 | + | ||
314 | //H5公告详情 | 442 | //H5公告详情 |
315 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { | 443 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { |
316 | var ( | 444 | var ( |
-
请 注册 或 登录 后发表评论