byPushHistoryLogic.go 2.3 KB

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