From 5b4ead9979f7ea84f40f035fca7d83b0375ab1e6 Mon Sep 17 00:00:00 2001 From: jhc Date: Sat, 22 Feb 2025 18:56:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleDao.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/dao/bundleDao.go b/internal/dao/bundleDao.go index 82e64c4..5711b56 100644 --- a/internal/dao/bundleDao.go +++ b/internal/dao/bundleDao.go @@ -1,6 +1,7 @@ package dao import ( + "fmt" "github.com/jinzhu/copier" "micro-bundle/internal/model" "micro-bundle/pb/bundle" @@ -59,12 +60,16 @@ func BundleList(req *bundle.BundleListRequest) (res *bundle.BundleListResponse, count := *query - if err = query.Find(&bundles).Error; err != nil { + if err = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize)).Find(&bundles).Error; err != nil { return res, commonErr.ReturnError(err, msg.ErrorGetBundleList, "获取套餐列表失败: ") } + fmt.Printf("bundles %+v\n", bundles) + _ = copier.CopyWithOption(&res.Bundles, bundles, copier.Option{DeepCopy: true}) + fmt.Printf("res.Bundles %+v\n", res.Bundles) + var total int64 count.Count(&total)