| | |
| | | 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 销售明细和产品关联搜索条件 |
| | |
| | | Keyword string |
| | | PageNum int |
| | | PageSize int |
| | | ProductIds []uint |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | 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 |