byPushHistoryLogic.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "github.com/gogf/gf/v2/util/gconv"
  6. "jyBXSubscribe/rpc/type/bxsubscribe"
  7. "strings"
  8. "jyBXSubscribe/api/internal/svc"
  9. "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. if req.IsEnt {
  33. for k, v := range req.Item {
  34. keyArr := gconv.Strings(v)
  35. if len(keyArr) == 0 {
  36. matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
  37. } else {
  38. for _, s := range keyArr {
  39. matchkeysArr = append(matchkeysArr, s)
  40. }
  41. }
  42. }
  43. if len(matchitemsArr) != 0 {
  44. matchitems = strings.Join(matchitemsArr, ",")
  45. }
  46. if len(matchkeysArr) != 0 {
  47. matchkeys = strings.Join(matchkeysArr, ",")
  48. strings.ReplaceAll(matchkeys, " ", ",")
  49. }
  50. } else {
  51. matchkeys = req.KeyWords
  52. }
  53. res, err := l.svcCtx.Suscribe.ByPushHistory(l.ctx, &bxsubscribe.SubscribeInfosReq{
  54. PageNum: req.PageNum,
  55. PageSize: req.PageSize,
  56. SelectTime: req.SelectTime,
  57. Area: req.Area,
  58. City: req.City,
  59. Industry: req.Industry,
  60. BuyerClass: req.BuyerClass,
  61. KeyWords: matchkeys,
  62. Subtype: req.Subtype,
  63. UserType: req.UserType,
  64. Price: req.Price,
  65. FileExists: req.FileExists,
  66. IsRead: req.IsRead,
  67. Source: req.Source,
  68. Staffs: req.Staffs,
  69. UserId: req.UserId,
  70. EntId: req.EntId,
  71. EntUserId: req.EntUserId,
  72. DeptId: req.DeptId,
  73. NewUserId: req.NewUserId,
  74. IsEnt: req.IsEnt,
  75. SelectIds: req.SelectIds,
  76. PositionType: req.PositionType,
  77. NotReturnCount: req.NotReturnCount,
  78. Item: matchitems,
  79. })
  80. if err != nil {
  81. return &types.CommonResp{
  82. Err_code: res.ErrorCode,
  83. Err_msg: res.ErrorMsg,
  84. Data: nil,
  85. }, nil
  86. }
  87. return &types.CommonResp{
  88. Err_code: res.ErrorCode,
  89. Err_msg: res.ErrorMsg,
  90. Data: res.Data,
  91. }, nil
  92. return
  93. }