byPushHistoryLogic.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. }
  49. } else {
  50. matchkeys = req.KeyWords
  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. })
  79. if err != nil {
  80. return &types.CommonResp{
  81. Err_code: res.ErrorCode,
  82. Err_msg: res.ErrorMsg,
  83. Data: nil,
  84. }, nil
  85. }
  86. return &types.CommonResp{
  87. Err_code: res.ErrorCode,
  88. Err_msg: res.ErrorMsg,
  89. Data: res.Data,
  90. }, nil
  91. return
  92. }