fix version 1
This commit is contained in:
@@ -15,21 +15,25 @@ import (
|
||||
// 供应商列表
|
||||
func Fetch(ctx context.Context, in *pb.MarketFetchRequest) (reply *pb.SupplyReply, err error) {
|
||||
var (
|
||||
cnt int64 = 0
|
||||
Offset int64 = (in.GetPageNo() - 1) * in.GetPageSize()
|
||||
data = make([]*models.MarketSupply, 0)
|
||||
cnt int64 = 0
|
||||
data = make([]*models.MarketSupply, 0)
|
||||
)
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 先归一化分页参数,再计算偏移量
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 10 {
|
||||
in.PageSize = 50
|
||||
}
|
||||
if in.GetPageSize() > 200 {
|
||||
in.PageSize = 200
|
||||
}
|
||||
Offset := (in.GetPageNo() - 1) * in.GetPageSize()
|
||||
tx := impl.DBService.Model(&models.MarketSupply{}).Where("status = ?", 1)
|
||||
if in.GetIdentity() != "" {
|
||||
tx.Where("identity = ?", in.GetIdentity())
|
||||
@@ -40,6 +44,6 @@ func Fetch(ctx context.Context, in *pb.MarketFetchRequest) (reply *pb.SupplyRepl
|
||||
}
|
||||
return &pb.SupplyReply{
|
||||
Data: ref(data),
|
||||
Count: int64(len(data)),
|
||||
Count: cnt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user