| | |
| | | // OperationDetails 操作明细表 |
| | | OperationDetails struct { |
| | | WmsModel |
| | | |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | OperationId int `json:"OperationId" gorm:"type:int;not null;comment:操作记录id"` //操作id |
| | | |
| | | ProductId int `json:"productId" gorm:"type:int;not null;comment:产品id"` //产品id |
| | | ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称 |
| | | Quantity decimal.Decimal `json:"quantity" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | FinishQuantity decimal.Decimal `json:"finishQuantity" gorm:"type:decimal(20,2);not null;comment:数量"` //完成数量 |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | OperationID int `json:"operationId" gorm:"type:int;not null;comment:操作记录id"` //操作id |
| | | ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:产品id"` //产品id |
| | | //ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"` //产品名称 |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | //Unit string `json:"unit" gorm:"type:varchar(31);comment:单位"` //单位 |
| | | Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` |
| | | } |
| | | |
| | | OperationDetailsSearch struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) SetID(id uint) *OperationDetailsSearch { |
| | | slf.ID = id |
| | | func (slf *OperationDetailsSearch) SetID(ID int) *OperationDetailsSearch { |
| | | slf.Id = ID |
| | | return slf |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) SetOperationId(operationId int) *OperationDetailsSearch { |
| | | slf.OperationID = operationId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) SetProductId(productId string) *OperationDetailsSearch { |
| | | slf.ProductId = productId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&OperationDetails{}) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.OperationID != 0 { |
| | | db = db.Where("operation_id = ?", slf.OperationID) |
| | | } |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id = ?", slf.ProductId) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | func (slf *OperationDetailsSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&OperationDetails{}).Error |
| | | return db.Unscoped().Delete(&OperationDetails{}).Error |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) First() (*OperationDetails, error) { |
| | |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | func (slf *OperationDetailsSearch) FindAll() ([]*OperationDetails, error) { |
| | | var ( |
| | | records = make([]*OperationDetails, 0) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, nil |
| | | } |