getsublistlogic.go 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package logic
  2. import (
  3. "context"
  4. "github.com/zeromicro/go-zero/core/logx"
  5. IC "jyBXSubscribe/rpc/init"
  6. "jyBXSubscribe/rpc/internal/svc"
  7. "jyBXSubscribe/rpc/model"
  8. "jyBXSubscribe/rpc/type/bxsubscribe"
  9. )
  10. type GetSubListLogic struct {
  11. ctx context.Context
  12. svcCtx *svc.ServiceContext
  13. logx.Logger
  14. }
  15. func NewGetSubListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSubListLogic {
  16. return &GetSubListLogic{
  17. ctx: ctx,
  18. svcCtx: svcCtx,
  19. Logger: logx.WithContext(ctx),
  20. }
  21. }
  22. // 获取订阅推送列表
  23. func (l *GetSubListLogic) GetSubList(in *bxsubscribe.SubscribeInfosReq) (*bxsubscribe.SubscribeInfosResp, error) {
  24. //1、推送信息已读标识
  25. //超级订阅 i_apppushunread=0
  26. //大会员 i_member_apppushunread=0
  27. //商机管理 i_entniche_apppushunread=0
  28. if in.PageNum == 1 {
  29. go model.UpdateUserPushUnread(in.UserId, in.UserType)
  30. }
  31. spqp := &model.SubPushQueryParam{
  32. Mgo_bidding: IC.MgoBidding, //mongo
  33. Bidding: IC.DB.Mongo.Bidding.Collection, //招标信息 表
  34. Bidding_back: IC.DB.Mongo.Bidding.CollectionBack, //招标信息备份数据 表名
  35. UserId: in.UserId, //用户id
  36. PageNum: int(in.PageNum), //当前页码
  37. PageSize: int(in.PageSize), //每页多少条数据
  38. SelectTime: in.SelectTime, //时间跨度
  39. Area: in.Area, //省份
  40. City: in.City, //城市
  41. Buyerclass: in.BuyerClass, //采购单位类型
  42. Subtype: in.Subtype, //信息类型
  43. Subscopeclass: in.Industry, //行业
  44. Key: in.KeyWords, //关键词
  45. Price: in.Price, //价格区间
  46. FileExists: in.FileExists, //是否有附件
  47. EntId: in.EntId, //商机管理企业id
  48. EntUserId: in.EntUserId, //商机管理用户id
  49. DeptId: in.DeptId, //商机管理部门id
  50. NewUserId: in.NewUserId,
  51. BaseServiceMysql: IC.BaseServiceMysql,
  52. IsEnt: in.IsEnt,
  53. }
  54. /* if in.UserType == "mType" {
  55. spqp.BaseServiceMysql = IC.MemberPushMysql
  56. } else if in.UserType == "eType" {
  57. spqp.BaseServiceMysql = IC.EntnichePushMysql
  58. } else {
  59. spqp.BaseServiceMysql = IC.PushMysql
  60. }*/
  61. hasNextPage, total, list := model.NewSubscribePush(in.UserType).Datas(spqp)
  62. /*
  63. *无推送记录生成推送记录
  64. *免费用户默认推送50条
  65. *大会员、新版商机管理、超级订阅用户 默认推送1000条记录
  66. */
  67. if in.PageNum == 1 && spqp.IsEmpty() && len(list) == 0 && in.IsEnt == false {
  68. hasNextPage, total, list = model.NewSubscribePush(in.UserType).DefaultDatas(spqp)
  69. }
  70. //查询是否收藏
  71. model.NewSubscribePush(in.UserType).MakeCollection(in.UserId, list)
  72. return &bxsubscribe.SubscribeInfosResp{
  73. Data: &bxsubscribe.SubscribeData{
  74. List: list,
  75. Count: total,
  76. HasNextPage: hasNextPage,
  77. },
  78. }, nil
  79. }