Pārlūkot izejas kodu

feat:返回条数调整

fuwencai 2 gadi atpakaļ
vecāks
revīzija
ddd32f1ce1
1 mainītis faili ar 14 papildinājumiem un 4 dzēšanām
  1. 14 4
      jyBXBuyer/rpc/internal/logic/buyerlistlogic.go

+ 14 - 4
jyBXBuyer/rpc/internal/logic/buyerlistlogic.go

@@ -32,10 +32,6 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	resp := &bxbuyer.BuyerListResp{
 		Data: &bxbuyer.BuyerData{},
 	}
-	// 采购单位搜索过来的 最多查100条
-	if in.PageSize*in.PageNum > IC.C.BuyerSearchLimit {
-		in.PageNum = IC.C.BuyerSearchLimit / in.PageSize
-	}
 	if in.PageNum < 1 {
 		in.PageNum = 1
 	}
@@ -45,6 +41,12 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	if in.PageSize > IC.C.BuyerSearchLimit {
 		in.PageSize = IC.C.BuyerSearchLimit
 	}
+	// 判断数量
+	// 采购单位搜索过来的 最多查BuyerSearchLimit条
+	if in.PageNum*in.PageSize > IC.C.BuyerSearchLimit && (in.PageNum-1)*in.PageSize >= IC.C.BuyerSearchLimit {
+		in.PageNum = IC.C.BuyerSearchLimit / in.PageSize
+	}
+
 	query, CountQuery := "", ""
 	buyerNames := []string{}
 	if model.CheckEmpty(in) {
@@ -88,6 +90,14 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
 	if len(resp.Data.List) > 0 && (in.UserId != "" || in.EntUserId != "") {
 		model.SupplyFollowInfo(in, buyerNames, resp)
 	}
+	if len(resp.Data.List) > 0 {
+		if in.PageNum*in.PageSize > IC.C.BuyerSearchLimit && (in.PageNum-1)*in.PageSize < IC.C.BuyerSearchLimit {
+			end := IC.C.BuyerSearchLimit - (in.PageNum-1)*in.PageSize
+			if len(resp.Data.List) > int(end) {
+				resp.Data.List = resp.Data.List[:end]
+			}
+		}
+	}
 	if resp.Data.Count > IC.C.BuyerSearchLimit {
 		resp.Data.Count = IC.C.BuyerSearchLimit
 	}