10 changed files with 230 additions and 26 deletions
@ -0,0 +1,65 @@ |
|||
package modelsstorage |
|||
|
|||
import ( |
|||
"key_performance_indicators/overall" |
|||
"strings" |
|||
) |
|||
|
|||
// 仓储系统菜单管理
|
|||
type AccesstoAddress struct { |
|||
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;index"` |
|||
Name string `json:"name" gorm:"column:name;type:varchar(100);comment:名称"` |
|||
Url string `json:"url" gorm:"column:url;type:varchar(100);comment:路径"` |
|||
Type int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:访问方式(1get,2post,3delet,4put,5全部)"` |
|||
RoleId int `json:"roleid" gorm:"column:role_id;type:int(1) unsigned;default:1;not null;comment:菜单对应的角色"` |
|||
Menuparent int `json:"menuparent" gorm:"column:menuparent;type:int(1) unsigned;default:0;not null;comment:父菜单,0代表无父菜单"` |
|||
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
Icon string `json:"icon" gorm:"icon:name;type:varchar(100);comment:图标"` |
|||
Target string `json:"target" gorm:"column:target;type:varchar(100);comment:目标"` |
|||
IsChild int `json:"ischild" gorm:"column:ischild;type:int(1) unsigned;default:1;not null;comment:是否有子菜单\r\n(1有2无)"` |
|||
} |
|||
|
|||
func (AccesstoAddress *AccesstoAddress) TableName() string { |
|||
return "accesstoaddress" |
|||
} |
|||
|
|||
// 编辑内容
|
|||
func (cont *AccesstoAddress) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Updates(saveData).Error |
|||
return |
|||
} |
|||
|
|||
// 获取内容
|
|||
func (cont *AccesstoAddress) 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 *AccesstoAddress) CountCont(whereMap interface{}) (countId int64) { |
|||
overall.CONSTANT_DB_Storage.Model(&cont).Where(whereMap).Count(&countId) |
|||
return |
|||
} |
|||
|
|||
// 读取全部信息
|
|||
func (cont *AccesstoAddress) ContMap(whereMap interface{}, field ...string) (countAry []AccesstoAddress, 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 *AccesstoAddress) DelCont(whereMap interface{}) (err error) { |
|||
err = overall.CONSTANT_DB_Storage.Where(whereMap).Delete(&cont).Error |
|||
return |
|||
} |
|||
Loading…
Reference in new issue