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