menu

package
v0.0.0-...-66ffdac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMenu

func AddMenu(c *gin.Context)

AddMenu 新增菜单

func DelMenu

func DelMenu(c *gin.Context)

DelMenu 删除菜单

func EditMenu

func EditMenu(c *gin.Context)

EditMenu 修改菜单

func GetMenuList

func GetMenuList(c *gin.Context)

GetMenuList 查看菜单列表

func GetMenuLists

func GetMenuLists(c *gin.Context)

GetMenuLists 查看菜单列表涵盖被禁用

Types

type BySort

type BySort []TreeList

BySort 一个处理TreeList排序的接口方法

func (BySort) Len

func (a BySort) Len() int

func (BySort) Less

func (a BySort) Less(i, j int) bool

func (BySort) Swap

func (a BySort) Swap(i, j int)
type Menu struct {
	Id         uint   `json:"id"`
	MenuCode   int    `json:"menu_code" gorm:"primarykey"`   //ID
	MenuName   string `json:"menu_name"`                     //menu名称
	ParentCode int    `json:"parent_code"`                   // 父级ID
	Url        string `json:"url"`                           //路径
	Icon       string `gorm:"type:varchar(20);" json:"icon"` // 图标
	Sort       int    `json:"sort"`                          // 排序值
	Authority  int    `json:"authority" gorm:"default:1"`    //权限:1为可用,2为不可用
}

Menu 菜单结构体

type MenusClass struct {
	TopMenu  []int  `json:"top_menu"`  //主分类
	MenuList []int  `json:"menu_list"` //子分类
	Menu     []Menu //菜单主数据
}

MenusClass 分拣菜单类别

func MenusClassFunc(role string) (m MenusClass)

MenusClassFunc 拆分传入的数据中的角色权限的菜单ID

type MenusSort []Menu

MenusSort 一个处理TreeList排序的接口方法

func (a MenusSort) Len() int
func (a MenusSort) Less(i, j int) bool
func (a MenusSort) Swap(i, j int)

type TreeList

type TreeList struct {
	Id         uint   `json:"id"`
	MenuCode   int    `gorm:"primarykey" json:"menu_code"`   //ID
	MenuName   string `json:"menu_name"`                     //menu名称
	ParentCode int    `json:"parent_code"`                   // 父级ID
	Url        string `json:"url"`                           //路径
	Icon       string `gorm:"type:varchar(20);" json:"icon"` // 图标
	Sort       int    `json:"sort"`                          // 排序值
	Authority  int    `json:"authority" gorm:"default:1"`    //权限:1为可用,2为不可用
	Children   []Menu `json:"children"`                      //子节点
	UpdateUser string `json:"update_user"`                   // 更新人
}

TreeList 定义一个序列化数据的结构体

func GetRoleMenu

func GetRoleMenu(users mod.User, role user.Role) []TreeList

GetRoleMenu 获取对应的菜单列表

func TreeListPrepare

func TreeListPrepare(menuTest Menu, Children []Menu) (treeList TreeList)

TreeListPrepare 菜单树数据准备

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL