subscribeListLogic.go 2.3 KB

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