subscribeListLogic.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. keyArr := gconv.Strings(v)
  38. if len(keyArr) == 0 {
  39. matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
  40. } else {
  41. for _, s := range keyArr {
  42. matchkeysArr = append(matchkeysArr, s)
  43. }
  44. }
  45. }
  46. if len(matchitemsArr) == 0 {
  47. matchkeys = strings.Join(matchkeysArr, ",")
  48. } else {
  49. matchitems = strings.Join(matchitemsArr, ",")
  50. }
  51. } else {
  52. matchkeys = req.KeyWords
  53. }
  54. res, err := l.svcCtx.Suscribe.GetSubList(l.ctx, &bxsubscribe.SubscribeInfosReq{
  55. PageNum: req.PageNum,
  56. PageSize: req.PageSize,
  57. SelectTime: req.SelectTime,
  58. Area: req.Area,
  59. City: req.City,
  60. Industry: req.Industry,
  61. BuyerClass: req.BuyerClass,
  62. KeyWords: matchkeys,
  63. Subtype: req.Subtype,
  64. UserType: req.UserType,
  65. Price: req.Price,
  66. FileExists: req.FileExists,
  67. IsRead: req.IsRead,
  68. Source: req.Source,
  69. Staffs: req.Staffs,
  70. UserId: req.UserId,
  71. EntId: req.EntId,
  72. EntUserId: req.EntUserId,
  73. DeptId: req.DeptId,
  74. NewUserId: req.NewUserId,
  75. IsEnt: req.IsEnt,
  76. PositionType: req.PositionType,
  77. NotReturnCount: req.NotReturnCount,
  78. Item: matchitems,
  79. })
  80. if err != nil {
  81. return &types.CommonResp{
  82. Err_code: res.ErrCode,
  83. Err_msg: res.ErrMsg,
  84. Data: nil,
  85. }, nil
  86. }
  87. return &types.CommonResp{
  88. Err_code: res.ErrCode,
  89. Err_msg: res.ErrMsg,
  90. Data: res.Data,
  91. }, nil
  92. }