| | |
| | | // Material 物料 |
| | | Material struct { |
| | | BaseModelString |
| | | Name string `gorm:"unique;type:varchar(191);not null;comment:物料名称" json:"name"` //物料名称 |
| | | Name string `gorm:"type:varchar(191);not null;comment:物料名称" json:"name"` //物料名称 |
| | | //MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"` |
| | | Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:物料类型(字符串)" json:"model"` //物料类型(字符串) |
| | | //Explain string `gorm:"type:varchar(512);comment:编号说明" json:"explain"` |
| | |
| | | //MaterialTypes []constvar.MaterialType |
| | | Keyword string |
| | | //SetTemplateType constvar.SetTemplateType |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Ids []string |
| | | Orm *gorm.DB |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Ids []string |
| | | Orm *gorm.DB |
| | | CategoryIds []int |
| | | } |
| | | |
| | | IdAndName struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MaterialSearch) SetCategoryIds(ids []int) *MaterialSearch { |
| | | slf.CategoryIds = ids |
| | | return slf |
| | | } |
| | | |
| | | // |
| | | //func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch { |
| | | // slf.SetTemplateType = setType |
| | |
| | | } |
| | | if slf.CategoryId > 0 { |
| | | db = db.Where("category_id = ?", slf.CategoryId) |
| | | } |
| | | if len(slf.CategoryIds) > 0 { |
| | | db = db.Where("category_id in ?", slf.CategoryIds) |
| | | } |
| | | |
| | | return db |
| | |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | Unit string `json:"unit" gorm:"type:varchar(31);comment:单位"` |
| | | } |
| | | |
| | | func (slf *MaterialSearch) Update(record *Material) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |