jiangshuai
2023-10-20 222399d441e1a759bae2a10685245ee90bc3fb6d
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
}