go-wxhelper/api/admin/menu/user.go

24 lines
506 B
Go
Raw Normal View History

2024-01-19 12:06:30 +08:00
package menu
import (
"github.com/gin-gonic/gin"
"wechat-robot/pkg/response"
"wechat-robot/service/menu"
)
// GetUserMenuTree
// @description: 获取用户权限内的菜单树
// @param ctx
func GetUserMenuTree(ctx *gin.Context) {
// 获取用户Id
userId := ctx.GetString("userId")
// 获取菜单树
tree, err := menu.GetUserMenus(userId)
if err != nil {
response.New(ctx).SetMsg("系统错误").SetError(err).Fail()
return
}
// 返回数据
response.New(ctx).SetData(tree).Success()
}