| | |
| | | // 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 { |
| | |
| | | slf.TemplateID = id |
| | | return slf |
| | | } |
| | | func (slf *MaterialSearch) SetCategoryId(id int) *MaterialSearch { |
| | | slf.CategoryId = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *MaterialSearch) SetCategoryIds(ids []int) *MaterialSearch { |
| | | slf.CategoryIds = ids |
| | | return slf |
| | | } |
| | | |
| | | // |
| | | //func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch { |
| | |
| | | //} |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ? or id LIKE ? ", "%"+slf.Keyword+"%", "%"+slf.Keyword+"%") |
| | | db = db.Where("name LIKE ? ", "%"+slf.Keyword+"%") |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | } |
| | | if slf.IsSale { |
| | | db = db.Where("is_sale = ?", 1) |
| | | } |
| | | 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 |
| | |
| | | } |
| | | return result.Max, nil |
| | | } |
| | | |
| | | type ResponseDisuseList struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Number string `json:"number" gorm:"type:varchar(255)"` //单号 |
| | | SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //源单号 |
| | | Status constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:状态"` //状态 |
| | | FromLocationID int `json:"fromLocationId" gorm:"type:int;not null;comment:源位置id"` //源位置id |
| | | FromLocation Location `json:"fromLocation" gorm:"foreignKey:FromLocationID;references:Id"` //源位置 |
| | | ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //目标位置 |
| | | ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:目标位置id"` //目标位置id |
| | | OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:安排日期"` |
| | | ContacterID int `json:"contacterID" gorm:"type:int;comment:联系人ID"` |
| | | ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:联系人姓名"` |
| | | CompanyID int `json:"companyID" gorm:"type:int;comment:公司ID-客户"` |
| | | CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:公司名称-客户"` |
| | | Comment string `json:"comment" gorm:"type:text;comment:备注"` |
| | | 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:单位"` |
| | | } |
| | | |
| | | 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 |
| | | } |