byPushHistoryLogic.go 2.3 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. 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. matchkeys = strings.Join(matchkeysArr, ",")
  45. } else {
  46. matchitems = strings.Join(matchitemsArr, ",")
  47. }
  48. } else {
  49. matchkeys = req.KeyWords
  50. }
  51. res, err := l.svcCtx.Suscribe.ByPushHistory(l.ctx, &bxsubscribe.SubscribeInfosReq{
  52. PageNum: req.PageNum,
  53. PageSize: req.PageSize,
  54. SelectTime: req.SelectTime,
  55. Area: req.Area,
  56. City: req.City,
  57. Industry: req.Industry,
  58. BuyerClass: req.BuyerClass,
  59. KeyWords: matchkeys,
  60. Subtype: req.Subtype,
  61. UserType: req.UserType,
  62. Price: req.Price,
  63. FileExists: req.FileExists,
  64. IsRead: req.IsRead,
  65. Source: req.Source,
  66. Staffs: req.Staffs,
  67. UserId: req.UserId,
  68. EntId: req.EntId,
  69. EntUserId: req.EntUserId,
  70. DeptId: req.DeptId,
  71. NewUserId: req.NewUserId,
  72. IsEnt: req.IsEnt,
  73. SelectIds: req.SelectIds,
  74. PositionType: req.PositionType,
  75. NotReturnCount: req.NotReturnCount,
  76. Item: matchitems,
  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. }