package logic import ( "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerinfo" "context" "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jyInfo/api/internal/svc" "app.yhyue.com/moapp/jyInfo/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type SupplySearchLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewSupplySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SupplySearchLogic { return &SupplySearchLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *SupplySearchLogic) SupplySearch(req *types.PubSupplyInfoReq) (resp *types.CommonRes, err error) { if req.UserId == "" { //未登录用户每次搜索100条数据 req.PageIndex = common.Int64All(common.If(req.PageIndex == 0, 1, req.PageIndex)) if req.PageIndex*req.PageSize > 100 { req.PageIndex = 1 req.PageSize = 100 } } supplySearch, err0 := l.svcCtx.Consumer.SupplyInfoSearch(l.ctx, &consumerinfo.SupplyInfoSearchReq{ Keywords: req.Keywords, SearchType: req.SearchType, Province: req.Province, City: req.City, Time: req.Time, Status: req.Status, PageSize: req.PageSize, PageIndex: req.PageIndex, }) if err0 != nil { return &types.CommonRes{ Err_code: -1, Err_msg: "错误", Data: nil, }, nil } return &types.CommonRes{ Err_code: common.IntAll(supplySearch.ErrCode), Err_msg: supplySearch.ErrMsg, Data: supplySearch.Data, }, nil }