checkSearchScreenLogic.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. for k1, v1 := range v {
  31. areaMap[k1] = &bxbase.District{
  32. District: v1,
  33. }
  34. }
  35. region[k] = &bxbase.Area{
  36. Area: areaMap,
  37. }
  38. }
  39. }
  40. res, err0 := l.svcCtx.Bxbase.CheckSearch(l.ctx, &bxbase.AddSearchReq{
  41. UserId: req.UserId,
  42. Type: req.Type,
  43. Keywords: req.Keywords,
  44. PublishTime: req.Publishtime,
  45. Area: req.Area,
  46. City: req.City,
  47. Subtype: req.Subtype,
  48. MinPrice: req.Minprice,
  49. MaxPrice: req.Maxprice,
  50. Industry: req.Industry,
  51. SelectType: req.SelectType,
  52. BuyerClass: req.Buyerclass,
  53. HasBuyerTel: req.Hasbuyertel,
  54. HasWinnerTel: req.Haswinnertel,
  55. FileExists: req.FileExists,
  56. NotKey: req.Notkey,
  57. AppId: req.AppId,
  58. SearchGroup: int64(req.SearchGroup),
  59. SearchMode: int64(req.SearchMode),
  60. WordsMode: int64(req.WordsMode),
  61. AdditionalWords: req.AdditionalWords,
  62. RegionMap: region,
  63. })
  64. if err0 != nil {
  65. return &types.CommonRes{
  66. Err_code: -1,
  67. Err_msg: "错误",
  68. Data: nil,
  69. }, nil
  70. }
  71. return &types.CommonRes{
  72. Err_code: common.IntAll(res.ErrCode),
  73. Err_msg: res.ErrMsg,
  74. Data: res.Data,
  75. }, nil
  76. }