byPushHistoryLogic.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
  5. "context"
  6. "github.com/gogf/gf/v2/util/gconv"
  7. "strings"
  8. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/svc"
  9. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/api/internal/types"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. )
  12. type ByPushHistoryLogic struct {
  13. logx.Logger
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. }
  17. func NewByPushHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ByPushHistoryLogic {
  18. return &ByPushHistoryLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. }
  23. }
  24. func (l *ByPushHistoryLogic) ByPushHistory(req *types.SubscribeReq) (resp *types.CommonResp, err error) {
  25. //关键词处理
  26. //分类
  27. matchitemsArr := []string{}
  28. matchitems := ""
  29. //关键词
  30. matchkeysArr := []string{}
  31. matchkeys := ""
  32. for k, v := range req.Item {
  33. keyArr := gconv.Strings(v)
  34. if len(keyArr) == 0 {
  35. matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
  36. } else {
  37. for _, s := range keyArr {
  38. matchkeysArr = append(matchkeysArr, s)
  39. }
  40. }
  41. }
  42. if len(matchitemsArr) != 0 {
  43. matchitems = strings.Join(matchitemsArr, ",")
  44. }
  45. if len(matchkeysArr) != 0 {
  46. matchkeys = strings.Join(matchkeysArr, ",")
  47. matchkeys = strings.ReplaceAll(matchkeys, " ", ",")
  48. }
  49. if req.PushTime != "" { //微信跳转过来的 按照推送时间查询导出
  50. req.SelectTime = req.PushTime
  51. }
  52. res, err := l.svcCtx.Suscribe.ByPushHistory(l.ctx, &bxsubscribe.SubscribeInfosReq{
  53. PageNum: req.PageNum,
  54. PageSize: req.PageSize,
  55. SelectTime: req.SelectTime,
  56. Area: req.Area,
  57. City: req.City,
  58. Industry: req.Industry,
  59. BuyerClass: req.BuyerClass,
  60. KeyWords: matchkeys,
  61. Subtype: req.Subtype,
  62. UserType: req.UserType,
  63. Price: req.Price,
  64. FileExists: req.FileExists,
  65. IsRead: req.IsRead,
  66. Source: req.Source,
  67. Staffs: req.Staffs,
  68. UserId: req.UserId,
  69. EntId: req.EntId,
  70. EntUserId: req.EntUserId,
  71. DeptId: req.DeptId,
  72. NewUserId: req.NewUserId,
  73. IsEnt: req.IsEnt,
  74. SelectIds: req.SelectIds,
  75. PositionType: req.PositionType,
  76. NotReturnCount: req.NotReturnCount,
  77. Item: matchitems,
  78. SelectKeys: req.SelectKeys,
  79. District: req.District,
  80. })
  81. if err != nil {
  82. return &types.CommonResp{
  83. Err_code: res.ErrorCode,
  84. Err_msg: res.ErrorMsg,
  85. Data: nil,
  86. }, nil
  87. }
  88. return &types.CommonResp{
  89. Err_code: res.ErrorCode,
  90. Err_msg: res.ErrorMsg,
  91. Data: res.Data,
  92. }, nil
  93. return
  94. }