addSearchScreenLogic.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 AddSearchScreenLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. r *http.Request
  16. }
  17. func NewAddSearchScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *AddSearchScreenLogic {
  18. return &AddSearchScreenLogic{
  19. Logger: logx.WithContext(ctx),
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. r: r,
  23. }
  24. }
  25. func (l *AddSearchScreenLogic) AddSearchScreen(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.AddSearch(l.ctx, &bxbase.AddSearchReq{
  43. UserId: req.UserId,
  44. Type: req.Type,
  45. Keywords: req.Keywords,
  46. PublishTime: req.Publishtime,
  47. City: req.City,
  48. Area: req.Area,
  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. InKey: req.InKey,
  60. AppId: req.AppId,
  61. SearchGroup: int64(req.SearchGroup),
  62. SearchMode: int64(req.SearchMode),
  63. WordsMode: int64(req.WordsMode),
  64. AdditionalWords: req.AdditionalWords,
  65. RegionMap: region,
  66. })
  67. if err0 != nil {
  68. return &types.CommonRes{
  69. Err_code: -1,
  70. Err_msg: "错误",
  71. Data: nil,
  72. }, nil
  73. }
  74. return &types.CommonRes{
  75. Err_code: common.IntAll(res.ErrCode),
  76. Err_msg: res.ErrMsg,
  77. Data: nil,
  78. }, nil
  79. }