jiangshuai
2023-10-26 be19d957b591ad27a47057929c4a8694f0776a1a
models/location_product.go
@@ -85,6 +85,11 @@
   return slf
}
func (slf *LocationProductSearch) SetAreaId(areaId int) *LocationProductSearch {
   slf.AreaId = areaId
   return slf
}
func (slf *LocationProductSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&LocationProduct{})
@@ -119,6 +124,10 @@
   if len(slf.LocationIds) > 0 {
      db = db.Where("location_id in (?)", slf.LocationIds)
   }
   if slf.AreaId != 0 {
      db = db.Where("area_id = ?", slf.AreaId)
   }
   return db
@@ -206,3 +215,11 @@
   return records, nil
}
func (slf *LocationProductSearch) FirstRes() (*LocationProduct, *gorm.DB) {
   var (
      record = new(LocationProduct)
      db     = slf.build()
   )
   return record, db.First(record)
}