package modelsstorage import ( "appPlatform/overall" "strings" ) // 仓储系统菜单管理 type Material struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` DepositoryId int64 `json:"depositoryid" gorm:"column:depository_id;type:bigint(20) unsigned;default:0;not null;comment:仓库编号"` Name string `json:"name" gorm:"column:mname;type:varchar(100);comment:材料名称"` Quantity int `json:"quantity" gorm:"column:type;quantity:int(11) unsigned;default:1;not null;comment:数量"` Amounts int `json:"amounts" gorm:"column:amounts;type:int(11) unsigned;default:1;not null;comment:总金额"` TypeId int64 `json:"typeid" gorm:"column:type_id;type:bigint(20) unsigned;default:0;not null;comment:材料种类id"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` Code string `json:"code" gorm:"column:code;type:varchar(255);comment:存货编码"` Version string `json:"version" gorm:"column:version;type:varchar(255);comment:规格型号"` Price int `json:"price" gorm:"column:price;type:int(11) unsigned;default:1;not null;comment:单价"` Unit string `json:"unit" gorm:"column:unit;type:varchar(255);comment:计量单位"` Texture string `json:"texture" gorm:"column:texture;type:varchar(255);comment:材质"` DepositoryCode string `json:"depositoryCode" gorm:"column:depositoryCode;type:varchar(255);comment:货位码(存放位置)"` Kingdeecode string `json:"kingdeecode" gorm:"column:kingdeecode;type:varchar(255);comment:计量单位"` NumberOfTemporary int `json:"numberoftemporary" gorm:"column:number_of_temporary;type:int(11) unsigned;default:1;not null;comment:临时数目(临时出库数目)"` } func (Material *Material) TableName() string { return "material" } // 编辑内容 func (cont *Material) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *Material) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_Storage.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } gormDb = gormDb.Where(whereMap) err = gormDb.First(&cont).Error return } // 根据条件获取总数 func (cont *Material) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *Material) ContMap(whereMap interface{}, field ...string) (countAry []Material, err error) { gormDb := overall.CONSTANT_DB_Storage.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } err = gormDb.Where(whereMap).Find(&countAry).Error return } // 删除内容 func (cont *Material) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_Storage.Where(whereMap).Delete(&cont).Error return }