zhangqian
2023-10-31 5f0170df9787c6f3ff17cc168b3f2e3f511453f6
model/salesDetailsProduct.go
@@ -10,8 +10,8 @@
type (
   // SalesDetailsProduct 销售明细和产品关联
   SalesDetailsProduct struct {
      SalesDetailsId int  `json:"id" gorm:"column:id;type:int;primary_key;AUTO_INCREMENT"`
      ProductId      uint `json:"name" gorm:"primary_key;column:name;type:varchar(255);not null;default:'';comment:名称"`
      SalesDetailsId int  `json:"id" gorm:"column:sales_details_id;type:int;primary_key;not null;default:0"`
      ProductId      uint `json:"name" gorm:"primary_key;column:product_id;type:int;not null;default:0;comment:产品id"`
   }
   // SalesDetailsProductSearch 销售明细和产品关联搜索条件
@@ -23,6 +23,7 @@
      Keyword     string
      PageNum     int
      PageSize    int
      ProductIds  []uint
   }
)
@@ -38,10 +39,18 @@
func (slf *SalesDetailsProductSearch) build() *gorm.DB {
   var db = slf.Orm.Model(&SalesDetailsProduct{})
   if len(slf.ProductIds) > 0 {
      db = db.Where("product_id in (?)", slf.ProductIds)
   }
   return db
}
func (slf *SalesDetailsProductSearch) SetProductIds(ids []uint) *SalesDetailsProductSearch {
   slf.ProductIds = ids
   return slf
}
func (slf *SalesDetailsProductSearch) Create(record *SalesDetailsProduct) error {
   var db = slf.build()
   return db.Create(record).Error