Default Changelist

This commit is contained in:
PandaGoAdmin
2022-06-24 12:20:40 +08:00
parent d098b2a860
commit 5e5c045b1c
4 changed files with 35 additions and 11 deletions

View File

@@ -36,7 +36,9 @@ func (m *MenuApi) GetMenuTreeSelect(rc *ctx.ReqCtx) {
// @Router /system/menu/menuRole [get]
// @Security X-TOKEN
func (m *MenuApi) GetMenuRole(rc *ctx.ReqCtx) {
rc.ResData = Build(*m.MenuApp.SelectMenuRole(rc.LoginAccount.RoleKey))
roleKey := rc.GinCtx.Query("roleKey")
biz.IsTrue(roleKey != "", "请传入角色Key")
rc.ResData = Build(*m.MenuApp.SelectMenuRole(roleKey))
}
// @Summary 获取角色的菜单树

View File

@@ -88,16 +88,10 @@ func (u *UserApi) Login(rc *ctx.ReqCtx) {
})
biz.ErrIsNil(err, "生成Token失败")
//前端权限
permis := u.RoleMenuApp.GetPermis(role.RoleId)
menus := u.MenuApp.SelectMenuRole(role.RoleKey)
rc.ResData = map[string]interface{}{
"user": login,
"permissions": permis,
"menus": Build(*menus),
"token": token,
"expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime,
"token": token,
"expire": time.Now().Unix() + config.Conf.Jwt.ExpireTime,
}
var loginLog logEntity.LogLogin
@@ -117,6 +111,31 @@ func (u *UserApi) Login(rc *ctx.ReqCtx) {
u.LogLogin.Insert(loginLog)
}
// @Tags Base
// @Summary 用户权限信息
// @Param userName query string false "userName"
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"成功"}"
// @Router /system/user/auth [get]
func (u *UserApi) Auth(rc *ctx.ReqCtx) {
userName := rc.GinCtx.Query("username")
biz.NotEmpty(userName, "用户名必传")
var user entity.SysUser
user.Username = userName
userData := u.UserApp.FindOne(user)
role := u.RoleApp.FindOne(userData.RoleId)
//前端权限
permis := u.RoleMenuApp.GetPermis(role.RoleId)
menus := u.MenuApp.SelectMenuRole(role.RoleKey)
rc.ResData = map[string]interface{}{
"user": userData,
"role": role,
"permissions": permis,
"menus": Build(*menus),
}
}
// @Tags Base
// @Summary 退出登录
// @Produce application/json