获取用户菜单列表
This commit is contained in:
parent
e4bf7e65e7
commit
6ffb8ca63b
@ -14,38 +14,6 @@ import (
|
|||||||
|
|
||||||
type Role struct{}
|
type Role struct{}
|
||||||
|
|
||||||
// GetRoleMenuList 获取登陆角色菜单列表
|
|
||||||
func (r *Role) GetRoleMenuList(c *gin.Context) {
|
|
||||||
roleId := c.GetInt64("RoleId")
|
|
||||||
if roleId == 0 {
|
|
||||||
responses.Fail(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
roleService := service.RoleService{}
|
|
||||||
|
|
||||||
// 获取角色身份
|
|
||||||
isAdmin, err := roleService.GetRoleIden(c)
|
|
||||||
if err != nil {
|
|
||||||
responses.FailWithMessage(err.Error(), c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取角色菜单
|
|
||||||
roleMenuList, err := roleService.GetRoleMenuList(roleId, isAdmin)
|
|
||||||
if err != nil {
|
|
||||||
responses.FailWithMessage(err.Error(), c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(roleMenuList) == 0 || roleMenuList == nil {
|
|
||||||
responses.FailWithMessage("请联系管理人员设置菜单", c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
responses.OkWithData(roleMenuList, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRolePage 获取角色列表-分页
|
// GetRolePage 获取角色列表-分页
|
||||||
func (r *Role) GetRolePage(c *gin.Context) {
|
func (r *Role) GetRolePage(c *gin.Context) {
|
||||||
RoleRequest := requests.RoleRequest{}
|
RoleRequest := requests.RoleRequest{}
|
||||||
|
|||||||
@ -264,3 +264,35 @@ func (b *User) LoginOut(c *gin.Context) {
|
|||||||
|
|
||||||
responses.Ok(c)
|
responses.Ok(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserMenuList 获取用户菜单列表
|
||||||
|
func (r *User) GetUserMenuList(c *gin.Context) {
|
||||||
|
roleId := c.GetInt64("RoleId")
|
||||||
|
if roleId == 0 {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
roleService := service.RoleService{}
|
||||||
|
|
||||||
|
// 获取用户角色身份
|
||||||
|
isAdmin, err := roleService.GetRoleIden(c)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取角色菜单
|
||||||
|
roleMenuList, err := roleService.GetRoleMenuList(roleId, isAdmin)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(roleMenuList) == 0 || roleMenuList == nil {
|
||||||
|
responses.FailWithMessage("请联系管理人员设置菜单", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
responses.OkWithData(roleMenuList, c)
|
||||||
|
}
|
||||||
|
|||||||
@ -73,9 +73,6 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// 角色
|
// 角色
|
||||||
roleGroup := adminGroup.Group("/role")
|
roleGroup := adminGroup.Group("/role")
|
||||||
{
|
{
|
||||||
// 获取登陆角色菜单列表
|
|
||||||
roleGroup.GET("menu", api.Role.GetRoleMenuList)
|
|
||||||
|
|
||||||
// 获取角色列表-分页
|
// 获取角色列表-分页
|
||||||
roleGroup.GET("", api.Role.GetRolePage)
|
roleGroup.GET("", api.Role.GetRolePage)
|
||||||
|
|
||||||
@ -137,6 +134,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
|
|
||||||
// 退出登陆
|
// 退出登陆
|
||||||
userGroup.PUT("loginout", api.User.LoginOut)
|
userGroup.PUT("loginout", api.User.LoginOut)
|
||||||
|
|
||||||
|
// 获取用户菜单列表
|
||||||
|
roleGroup.GET("menu", api.User.GetUserMenuList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接口
|
// 接口
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user