| | |
| | | //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 |
| | | } |