searchListLogic.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "github.com/zeromicro/go-zero/core/logx"
  6. IC "jyBXCore/api/init"
  7. "jyBXCore/api/internal/svc"
  8. "jyBXCore/api/internal/types"
  9. "jyBXCore/api/internal/util"
  10. "jyBXCore/rpc/type/bxcore"
  11. "log"
  12. "net/http"
  13. "time"
  14. )
  15. type SearchListLogic struct {
  16. logx.Logger
  17. ctx context.Context
  18. svcCtx *svc.ServiceContext
  19. r *http.Request
  20. w http.ResponseWriter
  21. }
  22. func NewSearchListLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request, w http.ResponseWriter) *SearchListLogic {
  23. return &SearchListLogic{
  24. Logger: logx.WithContext(ctx),
  25. ctx: ctx,
  26. svcCtx: svcCtx,
  27. r: r,
  28. w: w,
  29. }
  30. }
  31. func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonResp, err error) {
  32. t := time.Now()
  33. limitFlag, isNew := util.GetFlag(l.r, l.w, req.UserId)
  34. res, err := l.svcCtx.BxCore.GetSearchList(l.ctx, &bxcore.SearchReq{
  35. AppId: req.AppId,
  36. UserId: req.UserId,
  37. Phone: req.Phone,
  38. NewUserId: req.NewUserId,
  39. EntId: req.EntId,
  40. EntUserId: req.EntUserId,
  41. PageNum: req.PageNum,
  42. PageSize: req.PageSize,
  43. Province: req.Province,
  44. City: req.City,
  45. Subtype: req.Subtype,
  46. TopType: req.TopType,
  47. PublishTime: req.PublishTime,
  48. SelectType: req.SelectType,
  49. Price: req.Price,
  50. Industry: req.Industry,
  51. BuyerClass: req.BuyerClass,
  52. BuyerTel: req.BuyerTel,
  53. WinnerTel: req.WinnerTel,
  54. FileExists: req.FileExists,
  55. SearchGroup: req.SearchGroup,
  56. SearchMode: req.SearchMode,
  57. WordsMode: req.WordsMode,
  58. KeyWords: req.KeyWords,
  59. AdditionalWords: req.AdditionalWords,
  60. ExclusionWords: req.ExclusionWords,
  61. UserType: req.UserType,
  62. Platform: util.CheckPlatform(l.r),
  63. BidField: req.BidField,
  64. <<<<<<< HEAD
  65. PositionType: req.PositionType,
  66. PositionId: req.PositionId,
  67. AccountId: req.AccountId,
  68. MgoUserId: req.MgoUserId,
  69. =======
  70. LimitFlag: limitFlag,
  71. IsNew: isNew,
  72. >>>>>>> master
  73. })
  74. log.Println("请求接口耗时:", time.Since(t).Seconds())
  75. if err != nil {
  76. return &types.CommonResp{
  77. Err_code: res.ErrCode,
  78. Err_msg: res.ErrMsg,
  79. Data: nil,
  80. }, err
  81. }
  82. if req.UserId == "" {
  83. var data []map[string]interface{}
  84. detailMosaicTxt := IC.C.DetailMosaicTxt
  85. sm := common.StructToMapMore(IC.C.SearchMosaic)
  86. for _, v := range res.Data.List {
  87. d := common.StructToMapMore(v)
  88. for name, t1 := range sm {
  89. ts, _ := t1.(bool)
  90. if v1, ok := d[name]; ok && v1 != "" && v1 != 0 && ts {
  91. d[name] = detailMosaicTxt
  92. }
  93. }
  94. data = append(data, d)
  95. }
  96. dataAll := common.StructToMapMore(res.Data)
  97. dataAll["list"] = data
  98. return &types.CommonResp{
  99. Err_code: res.ErrCode,
  100. Err_msg: res.ErrMsg,
  101. Data: dataAll,
  102. }, nil
  103. }
  104. return &types.CommonResp{
  105. Err_code: res.ErrCode,
  106. Err_msg: res.ErrMsg,
  107. Data: res.Data,
  108. }, nil
  109. }