From b9a62531fb93aba42d13e62fd1b03d8dba112fa6 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 23 十月 2023 12:04:31 +0800 Subject: [PATCH] 位置修改 --- models/location_product.go | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/models/location_product.go b/models/location_product.go index c3f26c6..f42e2fe 100644 --- a/models/location_product.go +++ b/models/location_product.go @@ -22,12 +22,13 @@ LocationProductSearch struct { LocationProduct - Order string - PageNum int - PageSize int - Keyword string - Orm *gorm.DB - Preload bool + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + Preload bool + LocationIds []int } ) @@ -79,6 +80,11 @@ return slf } +func (slf *LocationProductSearch) SetLocationIds(locationIds []int) *LocationProductSearch { + slf.LocationIds = locationIds + return slf +} + func (slf *LocationProductSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProduct{}) @@ -111,6 +117,10 @@ db = db.Where("product_id=?", slf.ProductId) } + if len(slf.LocationIds) > 0 { + db = db.Where("location_id in (?)", slf.LocationIds) + } + return db } -- Gitblit v1.8.0