byPushHistoryLogic.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. 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. res, err := l.svcCtx.Suscribe.ByPushHistory(l.ctx, &bxsubscribe.SubscribeInfosReq{
  50. PageNum: req.PageNum,
  51. PageSize: req.PageSize,
  52. SelectTime: req.SelectTime,
  53. Area: req.Area,
  54. City: req.City,
  55. Industry: req.Industry,
  56. BuyerClass: req.BuyerClass,
  57. KeyWords: matchkeys,
  58. Subtype: req.Subtype,
  59. UserType: req.UserType,
  60. Price: req.Price,
  61. FileExists: req.FileExists,
  62. IsRead: req.IsRead,
  63. Source: req.Source,
  64. Staffs: req.Staffs,
  65. UserId: req.UserId,
  66. EntId: req.EntId,
  67. EntUserId: req.EntUserId,
  68. DeptId: req.DeptId,
  69. NewUserId: req.NewUserId,
  70. IsEnt: req.IsEnt,
  71. SelectIds: req.SelectIds,
  72. PositionType: req.PositionType,
  73. NotReturnCount: req.NotReturnCount,
  74. Item: matchitems,
  75. SelectKeys: req.SelectKeys,
  76. District: req.District,
  77. })
  78. if err != nil {
  79. return &types.CommonResp{
  80. Err_code: res.ErrorCode,
  81. Err_msg: res.ErrorMsg,
  82. Data: nil,
  83. }, nil
  84. }
  85. return &types.CommonResp{
  86. Err_code: res.ErrorCode,
  87. Err_msg: res.ErrorMsg,
  88. Data: res.Data,
  89. }, nil
  90. return
  91. }