Documentation
¶
Index ¶
- Constants
- Variables
- func BatchDelete(ctx context.Context, ids []int) (ok bool, err error)
- func InitPaths(ctx context.Context, m *Menu) error
- type BindRoleMenu
- type IsAdmin
- type Menu
- func (m *Menu) Create(ctx context.Context) (id int, err error)
- func (m *Menu) DeleteMenu(ctx context.Context, id int) error
- func (e *Menu) Get(ctx context.Context) (menus []*Menu, err error)
- func (m *Menu) GetMenuById(ctx context.Context, id int) (menu *Menu, err error)
- func (m *Menu) GetPage(ctx context.Context) (menus []*Menu, err error)
- func (m *Menu) SetMenu(ctx context.Context) (menus []*Menu, err error)
- func (m *Menu) SetMenuLabel(ctx context.Context) (mls []*MenuLabel, err error)
- func (m *Menu) Update(ctx context.Context, id int) (menu *Menu, err error)
- type MenuLabel
- type Role
- func (r *Role) Get(ctx context.Context) (role *Role, err error)
- func (r *Role) GetList(ctx context.Context) (roles []*Role, err error)
- func (r *Role) GetPage(ctx context.Context, limit, offset int) (roles []*Role, count int64, err error)
- func (r *Role) Insert(ctx context.Context) (id int, err error)
- func (r *Role) Update(ctx context.Context, id int) (updated *Role, err error)
Constants ¶
View Source
const ( NotAdminRole = 0 AdminRole = 1 )
View Source
const (
BindRoleMenuTableName = "bind_role_menu"
)
View Source
const MenuTableName = "menu"
View Source
const RoleTableName = "role"
Variables ¶
View Source
var ( ErrUpdateRoleNameNotAllowed = errors.New("角色名称不允许修改!") ErrUpdateRoleKeyNotAllowed = errors.New("角色标识不允许修改!") )
Functions ¶
func BatchDelete ¶
BatchDelete batch delete role by given id list and return result
Types ¶
type BindRoleMenu ¶
type BindRoleMenu struct {
RoleID int `gorm:"column:role_id" json:"role_id"`
MenuID int `gorm:"column:menu_id" json:"menu_id"`
RoleName string `gorm:"column:role_name" json:"role_name"`
CreateBy string `gorm:"column:create_by" json:"create_by"`
UpdateBy string `gorm:"column:update_by" json:"update_by"`
ID int `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
}
func (*BindRoleMenu) Delete ¶
func (rm *BindRoleMenu) Delete(ctx context.Context, roleId, menuId string) (err error)
func (*BindRoleMenu) Get ¶
func (rm *BindRoleMenu) Get(ctx context.Context) (rms []*BindRoleMenu, err error)
Get find bindRoleMenu models by give id, if id == 0, then find all
type Menu ¶
type Menu struct {
MenuID int `gorm:"column:menu_id;primary_key;AUTO_INCREMENT" json:"menu_id"`
MenuName string `gorm:"column:menu_name" json:"menu_name"`
Title string `gorm:"column:title" json:"title"`
Icon string `gorm:"column:icon" json:"icon"`
Path string `gorm:"column:path" json:"path"` // vue router
Paths string `gorm:"column:paths" json:"paths"` // router from parent to current node
MenuType string `gorm:"column:menu_type" json:"menu_type"` // C: 菜单, M: 目录, F: 按钮, A: 接口
Action string `gorm:"column:action" json:"action"`
Permission string `gorm:"column:permission" json:"permission"` // vue permission
ParentID int `gorm:"column:parent_id" json:"parent_id"`
NoCache string `gorm:"column:no_cache" json:"no_cache"`
Breadcrumb string `gorm:"column:breadcrumb" json:"breadcrumb"` // FIXME 未知
Component string `gorm:"column:component" json:"component"` // 组件路径
Sort int `gorm:"column:sort" json:"sort"`
Visible string `gorm:"column:visible" json:"visible"` // 可见性
CreateBy string `gorm:"column:create_by" json:"create_by"`
UpdateBy string `gorm:"column:update_by" json:"update_by"` // 是否外链
IsFrame int `gorm:"column:is_frame;default:0" json:"is_frame"`
CreateTime *time.Time `gorm:"column:create_time" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time" json:"update_time"`
DeleteTime *time.Time `gorm:"column:delete_time" json:"delete_time"`
Children []*Menu `json:"children"`
}
func RecursiveMenu ¶
RecursiveMenu find child menu from params menulist for params menu
func (*Menu) DeleteMenu ¶
DeleteMenu delete menu by given menu_id
func (*Menu) GetMenuById ¶
GetMenuById get menu by given menu_id
func (*Menu) SetMenu ¶
SetMenu find menu list by given condition and set children menu for each menu
func (*Menu) SetMenuLabel ¶
SetMenuLabel set menulabel list by give menu
type MenuLabel ¶
type Role ¶
type Role struct {
RoleID int `gorm:"primary_key;AUTO_INCREMENT" json:"role_id"`
RoleName string `gorm:"column:role_name" json:"role_name"`
Status string `gorm:"column:status" json:"status"`
RoleKey string `gorm:"column:role_key" json:"role_key"`
RoleSort int `gorm:"column:role_sort" json:"role_sort"`
Flag string `gorm:"column:flag" json:"flag"`
CreateBy string `gorm:"column:create_by" json:"create_by"`
UpdateBy string `gorm:"column:update_by" json:"update_by"`
Remark string `gorm:"column:remark" json:"remark"`
Admin int `gorm:"column:admin" json:"admin"`
CreateTime *time.Time `gorm:"column:create_time" json:"create_time" default:"2000-01-01 00:00:00"`
UpdateTime *time.Time `gorm:"column:update_time" json:"update_time" default:"2000-01-01 00:00:00"`
DeleteTime *time.Time `gorm:"column:delete_time" json:"delete_time" default:"2000-01-01 00:00:00"`
Params string `json:"params" gorm:"-"`
MenuIds []int `json:"menuIds" gorm:"-"`
DeptIds []int `json:"deptIds" gorm:"-"`
}
func (*Role) GetPage ¶
func (r *Role) GetPage(ctx context.Context, limit, offset int) (roles []*Role, count int64, err error)
GetPage get role list page by (role_id, role_name, status, role_key), return list, list length and an error
Click to show internal directories.
Click to hide internal directories.