fix version 1
This commit is contained in:
@@ -20,17 +20,21 @@ func Pending(ctx context.Context, in *pb.MarketFetchRequest) (reply *pb.AgencyRe
|
||||
}
|
||||
|
||||
var (
|
||||
cnt int64 = 0
|
||||
Offset int64 = (in.GetPageNo() - 1) * in.GetPageSize()
|
||||
data = make([]*models.MarketAgency, 0)
|
||||
cnt int64 = 0
|
||||
data = make([]*models.MarketAgency, 0)
|
||||
)
|
||||
|
||||
// 先归一化分页参数,再计算偏移量
|
||||
if in.GetPageNo() < 1 {
|
||||
in.PageNo = 1
|
||||
}
|
||||
if in.GetPageSize() < 0 {
|
||||
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.MarketAgency{}).Where("approve = 0").Order("created_at desc")
|
||||
if in.GetIdentity() != "" {
|
||||
tx.Where("identity = ?", in.GetIdentity())
|
||||
@@ -42,6 +46,6 @@ func Pending(ctx context.Context, in *pb.MarketFetchRequest) (reply *pb.AgencyRe
|
||||
|
||||
return &pb.AgencyReply{
|
||||
Data: ref(data),
|
||||
Count: int64(len(data)),
|
||||
Count: cnt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user