package models import ( "hr_server/overall" "strings" ) //菜单 type SystemMenu struct { Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` ParentId int64 `json:"parentId" gorm:"column:m_parent;type:bigint(30) unsigned;default:0;not null;comment:'父级(顶级:0)"` ApiUrl string `json:"apiUrl" gorm:"column:m_url;type:varchar(255);not null;comment:地址"` Time int64 `json:"time" gorm:"column:m_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` EiteTime int64 `json:"eiteTime" gorm:"column:m_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` UserId int64 `json:"userId" gorm:"column:m_user_id;type:bigint(20) unsigned;not null;default:0;comment:写入人"` Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"` } func (SystemMenu *SystemMenu) TableName() string { return "system_menu" } //菜单管理 type SystemMenuOperation struct { SystemMenu MenuPermit []MenuOperation `json:"menupermit"` } //根据条件获取总数 func (cont *SystemMenu) CountCont(whereMap map[string]interface{}) (countId int64) { overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Count(&countId) return } //获取行政组织内容 func (cont *SystemMenu) GetCont(whereMap map[string]interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_Master.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } gormDb = gormDb.Where(whereMap) err = gormDb.First(&cont).Error return }