package model /* 权限管理 */ type Menu struct { Id int64 `gorm:"primary_key;column:id" json:"id"` // 菜单ID Pid int64 `gorm:"column:pid" json:"pid"` // 菜单父级ID Title string `gorm:"column:title" json:"title"` // 菜单名称 Icon string `gorm:"column:icon" json:"icon"` // 菜单图标 Path string `gorm:"column:path" json:"path"` // 菜单路径 Component string `gorm:"column:component" json:"component"` // 菜单组件 Target int64 `gorm:"column:target" json:"target"` // 打开方式 0-组件 1-内链 2-外链 Permission string `gorm:"column:permission" json:"permission"` // 权限标识 Type int `gorm:"column:type" json:"type"` // 类型 0-菜单 1-节点 Status int `gorm:"column:status" json:"status"` // 状态 1-正常 2-禁用 Hide int `gorm:"column:hide" json:"hide"` // 类型 0-显示 1-隐藏 Note string `gorm:"column:note" json:"note"` // 备注 Sort int `gorm:"column:sort" json:"sort"` // 排序 Children []Menu `gorm:"-" json:"children,omitempty"` // 子菜单 Checked int `gorm:"-" json:"checked,omitempty"` // 是否选中-sys_role_menu表作用于权限分配时 Meta MenuMeta `gorm:"-" json:"meta,omitempty"` // 气泡 } func (Menu) TableName() string { return "menu" } type MenuMeta struct { Badge int64 `json:"badge"` // 消息数量 } type MenuShow struct { Menu Meta MenuMeta `gorm:"-" json:"meta"` // 气泡 } /* 角色 */ type Role struct { Id int64 `gorm:"primary_key;column:id" json:"id"` // 角色ID Name string `gorm:"column:name" json:"name" binding:"required"` // 角色名称 Memo string `gorm:"column:memo" json:"memo"` // 角色说明 Status int `gorm:"column:status" json:"status" binding:"required"` // 状态 1-正常 2-禁用 Sort int `gorm:"column:sort" json:"sort" binding:"required"` // 排序 CreateTime int64 `gorm:"column:create_time" json:"createTime"` // 创建时间 } func (Role) TableName() string { return "role" } type RoleMenu struct { Rid int64 `gorm:"primary_key;column:rid" json:"rid"` // ID RoleId int64 `gorm:"column:role_id" json:"role_id" binding:"required"` // 角色ID MenuId int64 `gorm:"column:menu_id" json:"menu_id" binding:"required"` // 菜单ID } func (RoleMenu) TableName() string { return "role_menu" } type UserRole struct { Uid int64 `gorm:"uid" json:"uid" binding:"required"` // 用户ID RoleId int64 `gorm:"role_id" json:"roleId" binding:"required"` // 权限ID } func (UserRole) TableName() string { return "user_role" }