menu

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MenuRoot  = "R"
	MenuApi   = "A"
	MenuPage  = "M"
	MenuGroup = "G"
	MenuBasic = "BA"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ListMenuRequest added in v1.0.15

type ListMenuRequest struct {
	Order   *string `json:"order"`
	OrderBy *string `json:"orderBy"`
	Title   *string `json:"title"`
}
type Menu struct {
	Id         uint32  `json:"id"`
	ParentId   uint32  `json:"parentId"`
	Title      string  `json:"title"`
	Type       string  `json:"type"`
	Keyword    *string `json:"keyword"`
	Icon       *string `json:"icon"`
	Api        *string `json:"api"`
	Method     *string `json:"method"`
	Path       *string `json:"path"`
	Permission *string `json:"permission"`
	Component  *string `json:"component"`
	Redirect   *string `json:"redirect"`
	Weight     *int32  `json:"weight"`
	IsHidden   *bool   `json:"isHidden"`
	IsCache    *bool   `json:"isCache"`
	IsHome     *bool   `json:"isHome"`
	IsAffix    *bool   `json:"isAffix"`
	CreatedAt  int64   `json:"createdAt"`
	UpdatedAt  int64   `json:"updatedAt"`
	Children   []*Menu `json:"Children"`
}
func (m *Menu) AppendChildren(child any)

AppendChildren 添加子节点

func (m *Menu) ChildrenNode() []tree.Tree

ChildrenNode 获取子节点

func (m *Menu) ID() uint32

ID 获取菜单树ID

func (m *Menu) Parent() uint32

Parent 获取父ID

type Repo

type Repo interface {
	// ListMenu 获取菜单信息列表
	ListMenu(ctx kratosx.Context, req *ListMenuRequest) ([]*Menu, uint32, error)

	// ListMenuByRoleId 获取指定角色的菜单列表
	ListMenuByRoleId(ctx kratosx.Context, id uint32) ([]*Menu, uint32, error)

	// CreateMenu 创建菜单信息
	CreateMenu(ctx kratosx.Context, req *Menu) (uint32, error)

	// UpdateMenu 更新菜单信息
	UpdateMenu(ctx kratosx.Context, req *Menu) error

	// DeleteMenu 删除菜单信息
	DeleteMenu(ctx kratosx.Context, ids []uint32) (uint32, error)

	// GetMenuParentIds 获取父菜单信息ID列表
	GetMenuParentIds(ctx kratosx.Context, id uint32) ([]uint32, error)

	// GetMenuChildrenIds 获取子菜单信息ID列表
	GetMenuChildrenIds(ctx kratosx.Context, id uint32) ([]uint32, error)

	// InitBasicMenu 初始化基础菜单api
	InitBasicMenu(ctx kratosx.Context)
}

type UseCase

type UseCase struct {
	// contains filtered or unexported fields
}

func NewUseCase

func NewUseCase(config *conf.Config, repo Repo) *UseCase

func (*UseCase) CreateMenu added in v1.0.15

func (u *UseCase) CreateMenu(ctx kratosx.Context, req *Menu) (uint32, error)

CreateMenu 创建菜单信息

func (*UseCase) DeleteMenu

func (u *UseCase) DeleteMenu(ctx kratosx.Context, ids []uint32) (uint32, error)

DeleteMenu 删除菜单信息

func (*UseCase) ListMenu added in v1.0.15

func (u *UseCase) ListMenu(ctx kratosx.Context, req *ListMenuRequest) ([]tree.Tree, uint32, error)

ListMenu 获取菜单信息列表树

func (*UseCase) ListMenuByCurRole added in v1.0.15

func (u *UseCase) ListMenuByCurRole(ctx kratosx.Context) ([]tree.Tree, uint32, error)

ListMenuByCurRole 获取当前角色的菜单树

func (*UseCase) UpdateMenu

func (u *UseCase) UpdateMenu(ctx kratosx.Context, req *Menu) error

UpdateMenu 更新菜单信息

Jump to

Keyboard shortcuts

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