models/location_product.go
@@ -28,6 +28,7 @@ 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 }