正在显示
7 个修改的文件
包含
402 行增加
和
27 行删除
@@ -12,7 +12,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | @@ -12,7 +12,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | ||
12 | 12 | ||
13 | 13 | ||
14 | #redis相关配置 | 14 | #redis相关配置 |
15 | -redis_add = "${REDIS_HOST||192.168.100.102}" | 15 | +redis_add = "${REDIS_HOST||127.0.0.1}" |
16 | redis_add_port = "${REDIS_PORT||6379}" | 16 | redis_add_port = "${REDIS_PORT||6379}" |
17 | redis_auth = "123456" | 17 | redis_auth = "123456" |
18 | 18 |
@@ -294,27 +294,6 @@ func (this *ChanceController) MySubmitChance() { | @@ -294,27 +294,6 @@ func (this *ChanceController) MySubmitChance() { | ||
294 | msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request)) | 294 | msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request)) |
295 | } | 295 | } |
296 | 296 | ||
297 | -//ChancePool 机会池 | ||
298 | -//@router /chancePool [post] | ||
299 | -func (this *ChanceController) ChancePool() { | ||
300 | - var msg *protocol.ResponseMessage | ||
301 | - defer func() { | ||
302 | - this.Resp(msg) | ||
303 | - }() | ||
304 | - var request *protocol.ChancePoolRequest | ||
305 | - if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
306 | - log.Error(err) | ||
307 | - msg = protocol.BadRequestParam(1) | ||
308 | - return | ||
309 | - } | ||
310 | - if b, m := this.Valid(request); !b { | ||
311 | - msg = m | ||
312 | - return | ||
313 | - } | ||
314 | - header := controllers.GetRequestHeader(this.Ctx) | ||
315 | - msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) | ||
316 | -} | ||
317 | - | ||
318 | //ChanceDetail 机会详情 | 297 | //ChanceDetail 机会详情 |
319 | //@router /chanceDetail [post] | 298 | //@router /chanceDetail [post] |
320 | func (this *ChanceController) ChanceDetail() { | 299 | func (this *ChanceController) ChanceDetail() { |
@@ -488,3 +467,66 @@ func (this *ChanceController) MyApproveChance() { | @@ -488,3 +467,66 @@ func (this *ChanceController) MyApproveChance() { | ||
488 | header := controllers.GetRequestHeader(this.Ctx) | 467 | header := controllers.GetRequestHeader(this.Ctx) |
489 | msg = protocol.NewReturnResponse(chance.MyApproveChance(header, request)) | 468 | msg = protocol.NewReturnResponse(chance.MyApproveChance(header, request)) |
490 | } | 469 | } |
470 | + | ||
471 | +//MyCollectChance 我的收藏 | ||
472 | +//@router /myCollectChance [post] | ||
473 | +func (this *ChanceController) MyCollectChance() { | ||
474 | + var msg *protocol.ResponseMessage | ||
475 | + defer func() { | ||
476 | + this.Resp(msg) | ||
477 | + }() | ||
478 | + var request *protocol.MyCollectChanceRequest | ||
479 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
480 | + log.Error(err) | ||
481 | + msg = protocol.BadRequestParam(1) | ||
482 | + return | ||
483 | + } | ||
484 | + if b, m := this.Valid(request); !b { | ||
485 | + msg = m | ||
486 | + return | ||
487 | + } | ||
488 | + header := controllers.GetRequestHeader(this.Ctx) | ||
489 | + msg = protocol.NewReturnResponse(chance.MyCollectChance(header, request)) | ||
490 | +} | ||
491 | + | ||
492 | +//MyThumbUpChance 我点赞的机会 | ||
493 | +//@router /myThumbUpChance [post] | ||
494 | +func (this *ChanceController) MyThumbUpChance() { | ||
495 | + var msg *protocol.ResponseMessage | ||
496 | + defer func() { | ||
497 | + this.Resp(msg) | ||
498 | + }() | ||
499 | + var request *protocol.MyThumbUpChanceRequest | ||
500 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
501 | + log.Error(err) | ||
502 | + msg = protocol.BadRequestParam(1) | ||
503 | + return | ||
504 | + } | ||
505 | + if b, m := this.Valid(request); !b { | ||
506 | + msg = m | ||
507 | + return | ||
508 | + } | ||
509 | + header := controllers.GetRequestHeader(this.Ctx) | ||
510 | + msg = protocol.NewReturnResponse(chance.MyThumbUpChance(header, request)) | ||
511 | +} | ||
512 | + | ||
513 | +//ChancePool 机会池 | ||
514 | +//@router /chancePool [post] | ||
515 | +func (this *ChanceController) ChancePool() { | ||
516 | + var msg *protocol.ResponseMessage | ||
517 | + defer func() { | ||
518 | + this.Resp(msg) | ||
519 | + }() | ||
520 | + var request *protocol.ChancePoolRequest | ||
521 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
522 | + log.Error(err) | ||
523 | + msg = protocol.BadRequestParam(1) | ||
524 | + return | ||
525 | + } | ||
526 | + if b, m := this.Valid(request); !b { | ||
527 | + msg = m | ||
528 | + return | ||
529 | + } | ||
530 | + header := controllers.GetRequestHeader(this.Ctx) | ||
531 | + msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) | ||
532 | +} |
@@ -173,3 +173,49 @@ order by create_at desc | @@ -173,3 +173,49 @@ order by create_at desc | ||
173 | } | 173 | } |
174 | return | 174 | return |
175 | } | 175 | } |
176 | + | ||
177 | +func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | ||
178 | + sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | ||
179 | +select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( | ||
180 | +select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1 | ||
181 | +and source_type=1 | ||
182 | +and (mark_flag&2)>0 | ||
183 | +)a left outer join chance b on a.source_id = b.id | ||
184 | +)a left outer join chance_data b on a.source_id =b.chance_id | ||
185 | +order by collect_time desc | ||
186 | +limit ?`) | ||
187 | + | ||
188 | + sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&2)>0` | ||
189 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil { | ||
190 | + return | ||
191 | + } | ||
192 | + if v != nil { | ||
193 | + if err = utils.ExecuteQueryAll(v, sql, lastId, lastId, uid, pageSize); err != nil { | ||
194 | + return | ||
195 | + } | ||
196 | + } | ||
197 | + return | ||
198 | +} | ||
199 | + | ||
200 | +func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) { | ||
201 | + sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( | ||
202 | +select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from ( | ||
203 | +select id collect_id,source_id,create_at collect_time from chance_favorite where (0=? or id>?) and user_id =? and enable_status=1 | ||
204 | +and source_type=1 | ||
205 | +and (mark_flag&1)>0 | ||
206 | +)a left outer join chance b on a.source_id = b.id | ||
207 | +)a left outer join chance_data b on a.source_id =b.chance_id | ||
208 | +order by collect_time desc | ||
209 | +limit ?`) | ||
210 | + | ||
211 | + sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&2)>0` | ||
212 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil { | ||
213 | + return | ||
214 | + } | ||
215 | + if v != nil { | ||
216 | + if err = utils.ExecuteQueryAll(v, sql, lastId, lastId, uid, pageSize); err != nil { | ||
217 | + return | ||
218 | + } | ||
219 | + } | ||
220 | + return | ||
221 | +} |
@@ -198,9 +198,29 @@ type ChanceApproveItemOrm struct { | @@ -198,9 +198,29 @@ type ChanceApproveItemOrm struct { | ||
198 | ChanceId int64 `orm:"column(chance_id)"` // 机会id | 198 | ChanceId int64 `orm:"column(chance_id)"` // 机会id |
199 | } | 199 | } |
200 | 200 | ||
201 | +/*MyCollectChance 我的收藏*/ | ||
202 | +type MyCollectChanceRequest struct { | ||
203 | + LastId int64 `json:"lastId"` | ||
204 | + PageSize int `json:"pageSize" valid:"Required"` | ||
205 | +} | ||
206 | +type MyCollectChanceResponse struct { | ||
207 | + List []CommonListItem `json:"list"` | ||
208 | + Total int `json:"total"` | ||
209 | +} | ||
210 | + | ||
211 | +/*MyThumbUpChance 我点赞的机会*/ | ||
212 | +type MyThumbUpChanceRequest struct { | ||
213 | + LastId int64 `json:"lastId"` | ||
214 | + PageSize int `json:"pageSize" valid:"Required"` | ||
215 | +} | ||
216 | +type MyThumbUpChanceResponse struct { | ||
217 | + List []CommonListItem `json:"list"` | ||
218 | + Total int `json:"total"` | ||
219 | +} | ||
220 | + | ||
201 | //机会池列表 | 221 | //机会池列表 |
202 | type ChancePoolItemOrm struct { | 222 | type ChancePoolItemOrm struct { |
203 | - Id int64 `orm:"column(id)"` | 223 | + ChanceId int64 `orm:"column(id)"` |
204 | Uid int64 `orm:"column(user_id)"` | 224 | Uid int64 `orm:"column(user_id)"` |
205 | CreateTime time.Time `orm:"column(create_at)"` | 225 | CreateTime time.Time `orm:"column(create_at)"` |
206 | SourceContent string `orm:"column(source_content)"` | 226 | SourceContent string `orm:"column(source_content)"` |
@@ -210,12 +230,60 @@ type ChancePoolItemOrm struct { | @@ -210,12 +230,60 @@ type ChancePoolItemOrm struct { | ||
210 | ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | 230 | ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 |
211 | 231 | ||
212 | //ApproveData string `json:"approveData"` //审核数据 | 232 | //ApproveData string `json:"approveData"` //审核数据 |
233 | + TemplateId int `orm:"column(audit_template_id)"` | ||
234 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
213 | 235 | ||
236 | + CommentTotal int `orm:"column(comment_total)"` | ||
237 | + ZanTotal int `orm:"column(zan_total)"` | ||
238 | + ViewTotal int `orm:"column(view_total)"` | ||
239 | +} | ||
240 | + | ||
241 | +//机会池收藏列表项 | ||
242 | +type ChanceCollectItemOrm struct { | ||
243 | + ChanceId int64 `orm:"column(id)"` | ||
244 | + Uid int64 `orm:"column(user_id)"` | ||
245 | + CreateTime time.Time `orm:"column(create_at)"` | ||
246 | + SourceContent string `orm:"column(source_content)"` | ||
247 | + ChanceEnableStatus int `orm:"column(enable_status)"` | ||
248 | + ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
249 | + Images string `orm:"column(images)"` | ||
250 | + Voices string `orm:"column(speechs)"` | ||
251 | + Videos string `orm:"column(videos)"` | ||
252 | + | ||
253 | + //ApproveData string `json:"approveData"` //审核数据 | ||
254 | + TemplateId int `orm:"column(audit_template_id)"` | ||
255 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
256 | + | ||
257 | + CommentTotal int `orm:"column(comment_total)"` | ||
258 | + ZanTotal int `orm:"column(zan_total)"` | ||
259 | + ViewTotal int `orm:"column(view_total)"` | ||
260 | + | ||
261 | + CollectId int64 `orm:"column(collect_id)"` //收藏id | ||
262 | + CollectTime time.Time `orm:"column(collect_time)"` //收藏时间 | ||
263 | +} | ||
264 | + | ||
265 | +//机会池收藏列表项 | ||
266 | +type ChanceThumbUpItemOrm struct { | ||
267 | + ChanceId int64 `orm:"column(id)"` | ||
268 | + Uid int64 `orm:"column(user_id)"` | ||
269 | + CreateTime time.Time `orm:"column(create_at)"` | ||
270 | + SourceContent string `orm:"column(source_content)"` | ||
271 | + ChanceEnableStatus int `orm:"column(enable_status)"` | ||
272 | + ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
273 | + Images string `orm:"column(images)"` | ||
274 | + Voices string `orm:"column(speechs)"` | ||
275 | + Videos string `orm:"column(videos)"` | ||
276 | + | ||
277 | + //ApproveData string `json:"approveData"` //审核数据 | ||
214 | TemplateId int `orm:"column(audit_template_id)"` | 278 | TemplateId int `orm:"column(audit_template_id)"` |
215 | ChanceTypeId int `orm:"column(chance_type_id)"` | 279 | ChanceTypeId int `orm:"column(chance_type_id)"` |
280 | + | ||
216 | CommentTotal int `orm:"column(comment_total)"` | 281 | CommentTotal int `orm:"column(comment_total)"` |
217 | ZanTotal int `orm:"column(zan_total)"` | 282 | ZanTotal int `orm:"column(zan_total)"` |
218 | ViewTotal int `orm:"column(view_total)"` | 283 | ViewTotal int `orm:"column(view_total)"` |
284 | + | ||
285 | + CollectId int64 `orm:"column(collect_id)"` //收藏id | ||
286 | + CollectTime time.Time `orm:"column(collect_time)"` //收藏时间 | ||
219 | } | 287 | } |
220 | 288 | ||
221 | /*ChanceDetail 机会详情*/ | 289 | /*ChanceDetail 机会详情*/ |
@@ -352,7 +420,9 @@ type CommonListItem struct { | @@ -352,7 +420,9 @@ type CommonListItem struct { | ||
352 | Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve | 420 | Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve |
353 | ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData | 421 | ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData |
354 | Message interface{} `json:"message,omitempty"` //消息 | 422 | Message interface{} `json:"message,omitempty"` //消息 |
355 | - Comment interface{} `json:"comment,omitempty"` //评论 | 423 | + CommentData interface{} `json:"commentData,omitempty"` //评论 |
424 | + CollectData interface{} `json:"collectData,omitempty"` //收藏数据 | ||
425 | + ThumbUpData interface{} `json:"thumbUpData,omitempty"` //点赞数据 | ||
356 | //我审核的-通过 | 426 | //我审核的-通过 |
357 | Score interface{} `json:"score,omitempty"` | 427 | Score interface{} `json:"score,omitempty"` |
358 | 428 | ||
@@ -380,3 +450,15 @@ type ChanceData struct { | @@ -380,3 +450,15 @@ type ChanceData struct { | ||
380 | IsThumbsUp bool `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞 | 450 | IsThumbsUp bool `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞 |
381 | IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否 | 451 | IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否 |
382 | } | 452 | } |
453 | + | ||
454 | +//收藏数据 | ||
455 | +type CollectData struct { | ||
456 | + Id int64 `json:"id"` | ||
457 | + CollectTime int64 `json:"collectTime"` //收藏时间 | ||
458 | +} | ||
459 | + | ||
460 | +//点赞数据 | ||
461 | +type ThumbUpData struct { | ||
462 | + Id int64 `json:"id"` | ||
463 | + ThumbUpTime int64 `json:"thumbUpTime"` //收藏时间 | ||
464 | +} |
@@ -177,6 +177,14 @@ func init() { | @@ -177,6 +177,14 @@ func init() { | ||
177 | 177 | ||
178 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 178 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
179 | beego.ControllerComments{ | 179 | beego.ControllerComments{ |
180 | + Method: "MyCollectChance", | ||
181 | + Router: `/myCollectChance`, | ||
182 | + AllowHTTPMethods: []string{"post"}, | ||
183 | + MethodParams: param.Make(), | ||
184 | + Params: nil}) | ||
185 | + | ||
186 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
187 | + beego.ControllerComments{ | ||
180 | Method: "MySubmitChance", | 188 | Method: "MySubmitChance", |
181 | Router: `/mySubmitChance`, | 189 | Router: `/mySubmitChance`, |
182 | AllowHTTPMethods: []string{"post"}, | 190 | AllowHTTPMethods: []string{"post"}, |
@@ -185,6 +193,14 @@ func init() { | @@ -185,6 +193,14 @@ func init() { | ||
185 | 193 | ||
186 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 194 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
187 | beego.ControllerComments{ | 195 | beego.ControllerComments{ |
196 | + Method: "MyThumbUpChance", | ||
197 | + Router: `/myThumbUpChance`, | ||
198 | + AllowHTTPMethods: []string{"post"}, | ||
199 | + MethodParams: param.Make(), | ||
200 | + Params: nil}) | ||
201 | + | ||
202 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
203 | + beego.ControllerComments{ | ||
188 | Method: "Permission", | 204 | Method: "Permission", |
189 | Router: `/permission`, | 205 | Router: `/permission`, |
190 | AllowHTTPMethods: []string{"post"}, | 206 | AllowHTTPMethods: []string{"post"}, |
@@ -864,7 +864,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | @@ -864,7 +864,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | ||
864 | commItem := protocol.CommonListItem{} | 864 | commItem := protocol.CommonListItem{} |
865 | { | 865 | { |
866 | item := protocol.ChanceItem{ | 866 | item := protocol.ChanceItem{ |
867 | - Id: chance.Id, | 867 | + Id: chance.ChanceId, |
868 | Provider: provider, | 868 | Provider: provider, |
869 | CreateTime: chance.CreateTime.Unix() * 1000, | 869 | CreateTime: chance.CreateTime.Unix() * 1000, |
870 | } | 870 | } |
@@ -882,7 +882,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | @@ -882,7 +882,7 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | ||
882 | CommentTotal: chance.CommentTotal, | 882 | CommentTotal: chance.CommentTotal, |
883 | PageViewTotal: chance.ViewTotal, | 883 | PageViewTotal: chance.ViewTotal, |
884 | } | 884 | } |
885 | - if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil { | 885 | + if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.ChanceId); err != nil { |
886 | log.Error(err) | 886 | log.Error(err) |
887 | continue | 887 | continue |
888 | } | 888 | } |
@@ -918,7 +918,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | @@ -918,7 +918,6 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | ||
918 | total int | 918 | total int |
919 | provider *protocol.BaseUserInfo | 919 | provider *protocol.BaseUserInfo |
920 | ) | 920 | ) |
921 | - rsp = &protocol.MyApproveChanceResponse{} | ||
922 | if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { | 921 | if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { |
923 | if err == orm.ErrNoRows { | 922 | if err == orm.ErrNoRows { |
924 | err = nil | 923 | err = nil |
@@ -981,6 +980,186 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | @@ -981,6 +980,186 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | ||
981 | return | 980 | return |
982 | } | 981 | } |
983 | 982 | ||
983 | +// 我的收藏 | ||
984 | +func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollectChanceRequest) (rsp *protocol.MyCollectChanceResponse, err error) { | ||
985 | + var ( | ||
986 | + myChances []protocol.ChanceCollectItemOrm | ||
987 | + total int | ||
988 | + provider *protocol.BaseUserInfo | ||
989 | + ) | ||
990 | + if total, err = models.GetChanceCollect(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { | ||
991 | + if err == orm.ErrNoRows { | ||
992 | + err = nil | ||
993 | + return | ||
994 | + } | ||
995 | + log.Error(err) | ||
996 | + return | ||
997 | + } | ||
998 | + rsp = &protocol.MyCollectChanceResponse{Total: total} | ||
999 | + for i := 0; i < len(myChances); i++ { | ||
1000 | + chance := myChances[i] | ||
1001 | + commItem := protocol.CommonListItem{} | ||
1002 | + commItem.ReviewStatus = chance.ReviewStatus | ||
1003 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
1004 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
1005 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
1006 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
1007 | + } else { | ||
1008 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
1009 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
1010 | + log.Error(err) | ||
1011 | + //return | ||
1012 | + } else { | ||
1013 | + item := protocol.ChanceItem{ | ||
1014 | + Id: chance.ChanceId, | ||
1015 | + Provider: provider, | ||
1016 | + //CreateTime: chance.CreateTime.Unix() * 1000, | ||
1017 | + } | ||
1018 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
1019 | + item.FormList = clearEmptyForm(item.FormList) | ||
1020 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
1021 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
1022 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
1023 | + commItem.Chance = item | ||
1024 | + } | ||
1025 | + } | ||
1026 | + commItem.ReviewStatus = chance.ReviewStatus | ||
1027 | + { | ||
1028 | + var chanceData = protocol.ChanceData{ | ||
1029 | + ThumbsUpTotal: chance.ZanTotal, | ||
1030 | + CommentTotal: chance.CommentTotal, | ||
1031 | + PageViewTotal: chance.ViewTotal, | ||
1032 | + } | ||
1033 | + chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId) | ||
1034 | + commItem.ChanceData = chanceData | ||
1035 | + } | ||
1036 | + { | ||
1037 | + //做一次查询 查回所有的模板数据 | ||
1038 | + commItem.ChanceTemplate = getTemplate(chance.TemplateId) | ||
1039 | + commItem.ChanceType = getChanceType(chance.ChanceTypeId) | ||
1040 | + } | ||
1041 | + { | ||
1042 | + //收藏数据 | ||
1043 | + commItem.CollectData = protocol.CollectData{ | ||
1044 | + Id: chance.CollectId, | ||
1045 | + CollectTime: chance.CollectTime.Unix() * 1000, | ||
1046 | + } | ||
1047 | + } | ||
1048 | + rsp.List = append(rsp.List, commItem) | ||
1049 | + } | ||
1050 | + return | ||
1051 | +} | ||
1052 | + | ||
1053 | +//我点赞的机会 | ||
1054 | +func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUpChanceRequest) (rsp *protocol.MyThumbUpChanceResponse, err error) { | ||
1055 | + var ( | ||
1056 | + myChances []protocol.ChanceThumbUpItemOrm | ||
1057 | + total int | ||
1058 | + provider *protocol.BaseUserInfo | ||
1059 | + ) | ||
1060 | + if total, err = models.GetChanceThumbUp(header.UserId, request.LastId, request.PageSize, &myChances); err != nil { | ||
1061 | + if err == orm.ErrNoRows { | ||
1062 | + err = nil | ||
1063 | + return | ||
1064 | + } | ||
1065 | + log.Error(err) | ||
1066 | + return | ||
1067 | + } | ||
1068 | + rsp = &protocol.MyThumbUpChanceResponse{Total: total} | ||
1069 | + for i := 0; i < len(myChances); i++ { | ||
1070 | + chance := myChances[i] | ||
1071 | + commItem := protocol.CommonListItem{} | ||
1072 | + commItem.ReviewStatus = chance.ReviewStatus | ||
1073 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
1074 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
1075 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
1076 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
1077 | + } else { | ||
1078 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
1079 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
1080 | + log.Error(err) | ||
1081 | + //return | ||
1082 | + } else { | ||
1083 | + item := protocol.ChanceItem{ | ||
1084 | + Id: chance.ChanceId, | ||
1085 | + Provider: provider, | ||
1086 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
1087 | + } | ||
1088 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
1089 | + item.FormList = clearEmptyForm(item.FormList) | ||
1090 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
1091 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
1092 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
1093 | + commItem.Chance = item | ||
1094 | + } | ||
1095 | + } | ||
1096 | + commItem.ReviewStatus = chance.ReviewStatus | ||
1097 | + { | ||
1098 | + var chanceData = protocol.ChanceData{ | ||
1099 | + ThumbsUpTotal: chance.ZanTotal, | ||
1100 | + CommentTotal: chance.CommentTotal, | ||
1101 | + PageViewTotal: chance.ViewTotal, | ||
1102 | + } | ||
1103 | + chanceData.IsThumbsUp, chanceData.IsCollect, _ = getChanceMarkFlag(header, chance.ChanceId) | ||
1104 | + commItem.ChanceData = chanceData | ||
1105 | + } | ||
1106 | + { | ||
1107 | + //做一次查询 查回所有的模板数据 | ||
1108 | + commItem.ChanceTemplate = getTemplate(chance.TemplateId) | ||
1109 | + commItem.ChanceType = getChanceType(chance.ChanceTypeId) | ||
1110 | + } | ||
1111 | + { | ||
1112 | + //收藏数据 | ||
1113 | + commItem.ThumbUpData = protocol.ThumbUpData{ | ||
1114 | + Id: chance.CollectId, | ||
1115 | + ThumbUpTime: chance.CollectTime.Unix() * 1000, | ||
1116 | + } | ||
1117 | + } | ||
1118 | + rsp.List = append(rsp.List, commItem) | ||
1119 | + } | ||
1120 | + return | ||
1121 | +} | ||
1122 | + | ||
1123 | +//获取机会点赞/收藏状态 | ||
1124 | +func getChanceMarkFlag(header *protocol.RequestHeader, chanceId int64) (isThumbsUp, isCollect bool, err error) { | ||
1125 | + var flag int | ||
1126 | + if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chanceId); err != nil { | ||
1127 | + log.Error(err) | ||
1128 | + return | ||
1129 | + } | ||
1130 | + isThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan | ||
1131 | + isCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect | ||
1132 | + return | ||
1133 | +} | ||
1134 | + | ||
1135 | +//获取模板 | ||
1136 | +func getTemplate(templateId int) protocol.NameItem { | ||
1137 | + if template, e := models.GetAuditTemplateById(int64(templateId)); e == nil { | ||
1138 | + item := protocol.NameItem{ | ||
1139 | + Id: int(template.Id), | ||
1140 | + Name: template.Name, | ||
1141 | + } | ||
1142 | + return item | ||
1143 | + } else { | ||
1144 | + log.Error(templateId, e) | ||
1145 | + } | ||
1146 | + return protocol.NameItem{} | ||
1147 | +} | ||
1148 | + | ||
1149 | +//获取机会一级分类 | ||
1150 | +func getChanceType(chanceTypeId int) protocol.NameItem { | ||
1151 | + if template, e := models.GetChanceTypeById(chanceTypeId); e == nil { | ||
1152 | + item := protocol.NameItem{ | ||
1153 | + Id: int(template.Id), | ||
1154 | + Name: template.Name, | ||
1155 | + } | ||
1156 | + return item | ||
1157 | + } else { | ||
1158 | + log.Error(chanceTypeId, e) | ||
1159 | + } | ||
1160 | + return protocol.NameItem{} | ||
1161 | +} | ||
1162 | + | ||
984 | func jsonUnmarshal(jsonData string, v interface{}) { | 1163 | func jsonUnmarshal(jsonData string, v interface{}) { |
985 | if len(jsonData) == 0 { | 1164 | if len(jsonData) == 0 { |
986 | return | 1165 | return |
@@ -373,6 +373,16 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | @@ -373,6 +373,16 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | ||
373 | for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 { | 373 | for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 { |
374 | total = 0 | 374 | total = 0 |
375 | switch flag { | 375 | switch flag { |
376 | + case protocol.CollectStatic: //收藏 | ||
377 | + if total, err = models.GetChanceCollect(header.UserId, 0, 0, nil); err != nil { | ||
378 | + log.Error(err) | ||
379 | + } | ||
380 | + break | ||
381 | + case protocol.ZanStatic: //点赞 | ||
382 | + if total, err = models.GetChanceThumbUp(header.UserId, 0, 0, nil); err != nil { | ||
383 | + log.Error(err) | ||
384 | + } | ||
385 | + break | ||
376 | case protocol.MyCommitChance: | 386 | case protocol.MyCommitChance: |
377 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { | 387 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { |
378 | log.Error(err) | 388 | log.Error(err) |
-
请 注册 或 登录 后发表评论