checkSearchScreenLogic.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "jyBXBase/rpc/type/bxbase"
  6. "net/http"
  7. "jyBXBase/api/internal/svc"
  8. "jyBXBase/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type CheckSearchScreenLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. r *http.Request
  16. }
  17. func NewCheckSearchScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *CheckSearchScreenLogic {
  18. return &CheckSearchScreenLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. r: r,
  23. }
  24. }
  25. func (l *CheckSearchScreenLogic) CheckSearchScreen(req *types.AddSearchScreen) (resp *types.CommonRes, err error) {
  26. region := map[string]*bxbase.Area{}
  27. if req.RegionMap != nil {
  28. for k, v := range req.RegionMap {
  29. areaMap := map[string]*bxbase.District{}
  30. if v != nil {
  31. for k1, v1 := range v {
  32. areaMap[k1] = &bxbase.District{
  33. District: v1,
  34. }
  35. }
  36. }
  37. region[k] = &bxbase.Area{
  38. Area: areaMap,
  39. }
  40. }
  41. }
  42. res, err0 := l.svcCtx.Bxbase.CheckSearch(l.ctx, &bxbase.AddSearchReq{
  43. UserId: req.UserId,
  44. Type: req.Type,
  45. Keywords: req.Keywords,
  46. PublishTime: req.Publishtime,
  47. Area: req.Area,
  48. City: req.City,
  49. Subtype: req.Subtype,
  50. MinPrice: req.Minprice,
  51. MaxPrice: req.Maxprice,
  52. Industry: req.Industry,
  53. SelectType: req.SelectType,
  54. BuyerClass: req.Buyerclass,
  55. HasBuyerTel: req.Hasbuyertel,
  56. HasWinnerTel: req.Haswinnertel,
  57. FileExists: req.FileExists,
  58. NotKey: req.Notkey,
  59. AppId: req.AppId,
  60. SearchGroup: int64(req.SearchGroup),
  61. SearchMode: int64(req.SearchMode),
  62. WordsMode: int64(req.WordsMode),
  63. AdditionalWords: req.AdditionalWords,
  64. RegionMap: region,
  65. })
  66. if err0 != nil {
  67. return &types.CommonRes{
  68. Err_code: -1,
  69. Err_msg: "错误",
  70. Data: nil,
  71. }, nil
  72. }
  73. return &types.CommonRes{
  74. Err_code: common.IntAll(res.ErrCode),
  75. Err_msg: res.ErrMsg,
  76. Data: res.Data,
  77. }, nil
  78. }