36 lines
3.6 KiB
Go
36 lines
3.6 KiB
Go
|
|
package models
|
||
|
|
|
||
|
|
import coreTypes "git.apinb.com/bsm-sdk/core/types"
|
||
|
|
|
||
|
|
// 权限模型
|
||
|
|
type MgtPermission struct {
|
||
|
|
coreTypes.Std_IICUDS // 标准字段
|
||
|
|
Title string `gorm:"column:title;type:varchar(255);" json:"title"` // 权限名称
|
||
|
|
TitleEn string `gorm:"column:title_en;type:varchar(255);" json:"title_en"` // 权限名称
|
||
|
|
Code string `gorm:"column:code;type:varchar(255);uniqueIndex:idx_mgt_pmn_app_code" json:"code"` // 权限标识,与 app_id 联合唯一
|
||
|
|
Description string `gorm:"column:description;type:text" json:"description"` // 权限描述
|
||
|
|
Appid uint `gorm:"column:app_id;uniqueIndex:idx_mgt_pmn_app_code" json:"app_id"` // 应用ID
|
||
|
|
ParentID uint `gorm:"column:parent_id;default:0" json:"parent_id" ` // 父级ID
|
||
|
|
MenuPath string `gorm:"column:menu_path;" json:"menu_path"` // 菜单路径
|
||
|
|
MenuIcon string `gorm:"column:menu_icon;" json:"menu_icon"` // 菜单图标
|
||
|
|
SortKey int8 `gorm:"column:sort_key;default:0;" json:"sort_key"` // 排序键
|
||
|
|
Type int8 `gorm:"column:type;comment:1=菜单 2=按钮" json:"type"` // 类型 1=菜单 2=按钮
|
||
|
|
Component string `gorm:"column:component;type:varchar(255)" json:"component"` // 组件路径 非必填
|
||
|
|
IsWebPage bool `gorm:"column:is_web_page;default:0" json:"is_web_page"`
|
||
|
|
IsNewTab bool `gorm:"column:is_new_tab;default:0" json:"is_new_tab"` // 是否在新标签页打开 非必填
|
||
|
|
IsFull bool `gorm:"column:is_full;default:0" json:"is_full"` // 单独页面,不包含菜单,默认为 false
|
||
|
|
HideMenu bool `gorm:"column:hide_menu;default:0" json:"hide_menu"` // 隐藏菜单栏的菜单,默认为 false
|
||
|
|
WebUrl string `gorm:"column:web_url;type:varchar(500)" json:"web_url"` // 网页地址
|
||
|
|
Users []MgtUser `gorm:"many2many:mgt_link_user_pmn;foreignKey:ID;joinForeignKey:pmn_id;References:ID;joinReferences:user_id" json:"users,omitempty"` // 权限关联的用户
|
||
|
|
Roles []MgtRole `gorm:"many2many:mgt_link_role_pmn;foreignKey:ID;joinForeignKey:pmn_id;References:ID;joinReferences:role_id" json:"roles,omitempty"` // 权限关联的角色
|
||
|
|
Departments []MgtDepartment `gorm:"many2many:mgt_link_dpt_pmn;foreignKey:ID;joinForeignKey:pmn_id;References:ID;joinReferences:dpt_id" json:"departments,omitempty"` // 关联的部门(部门替代用户组)
|
||
|
|
Applications MgtApplication `gorm:"foreignKey:Appid;references:ID" json:"applications,omitempty"`
|
||
|
|
Children []MgtPermission `gorm:"foreignKey:ParentID;references:ID" json:"children,omitempty"` // 子集
|
||
|
|
}
|
||
|
|
|
||
|
|
func (MgtPermission) TableName() string { return "mgt_permission" }
|
||
|
|
|
||
|
|
// func init() {
|
||
|
|
// database.AppendMigrate(&Permission{})
|
||
|
|
// }
|