subscribeListLogic.go 2.5 KB

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