supplysearchlogic.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package logic
  2. import (
  3. "context"
  4. "jyInfo/rpc/consumer/consumer"
  5. "app.yhyue.com/moapp/jybase/common"
  6. "jyInfo/api/internal/svc"
  7. "jyInfo/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type SupplySearchLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewSupplySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SupplySearchLogic {
  16. return &SupplySearchLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *SupplySearchLogic) SupplySearch(req *types.PubSupplyInfoReq) (resp *types.CommonRes, err error) {
  23. //默认每页五十条
  24. if req.PageSize == 0 {
  25. req.PageSize = 50
  26. }
  27. //默认第一页
  28. if req.PageIndex == 0 {
  29. req.PageIndex = 1
  30. }
  31. supplySearch, err0 := l.svcCtx.Consumer.SupplyInfoSearch(l.ctx, &consumer.SupplyInfoSearchReq{
  32. Keywords: req.Keywords,
  33. SearchType: req.SearchType,
  34. Province: req.Province,
  35. City: req.City,
  36. Time: req.Time,
  37. Status: req.Status,
  38. PageSize: req.PageSize,
  39. PageIndex: req.PageIndex,
  40. })
  41. if err0 != nil {
  42. return &types.CommonRes{
  43. Err_code: -1,
  44. Err_msg: "错误",
  45. Data: nil,
  46. }, nil
  47. }
  48. return &types.CommonRes{
  49. Err_code: common.IntAll(supplySearch.ErrCode),
  50. Err_msg: supplySearch.ErrMsg,
  51. Data: supplySearch.Data,
  52. }, nil
  53. }