From b465206cf844644a417c26308cc94acff25db19c Mon Sep 17 00:00:00 2001 From: thinkgem Date: Sun, 7 Jul 2019 17:19:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E5=88=87=E6=8D=A2=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=A7=92=E8=89=B2=E5=B1=95=E7=A4=BA=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/sys/web/LoginController.java | 25 ++++++++++++++++--- .../modules/sys/sysIndex/topMenuUser.html | 15 +++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java b/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java index 9511c46f..6ad72def 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java @@ -360,12 +360,29 @@ public class LoginController extends BaseController{ @RequiresPermissions("user") @RequestMapping(value = "switch/{sysCode}") public String switchSys(@PathVariable String sysCode) { - User user = UserUtils.getUser(); - if (user.isSuperAdmin() && StringUtils.isNotBlank(sysCode)){ - Session session = UserUtils.getSession(); + Session session = UserUtils.getSession(); + if (StringUtils.isNotBlank(sysCode)){ session.setAttribute("sysCode", sysCode); - UserUtils.removeCache(UserUtils.CACHE_AUTH_INFO+"_"+session.getId()); + }else{ + session.removeAttribute("sysCode"); } + UserUtils.removeCache(UserUtils.CACHE_AUTH_INFO+"_"+session.getId()); + return REDIRECT + adminPath + "/index"; + } + + /** + * 切换角色菜单(仅超级管理员有权限) + */ + @RequiresPermissions("user") + @RequestMapping(value = {"switchRole","switchRole/{roleCode}"}) + public String switchRole(@PathVariable(required=false) String roleCode) { + Session session = UserUtils.getSession(); + if (StringUtils.isNotBlank(roleCode)){ + session.setAttribute("roleCode", roleCode); + }else{ + session.removeAttribute("roleCode"); + } + UserUtils.removeCache(UserUtils.CACHE_AUTH_INFO+"_"+session.getId()); return REDIRECT + adminPath + "/index"; } diff --git a/modules/core/src/main/resources/views/themes/default/modules/sys/sysIndex/topMenuUser.html b/modules/core/src/main/resources/views/themes/default/modules/sys/sysIndex/topMenuUser.html index cfc8e1f5..aeaa3c20 100644 --- a/modules/core/src/main/resources/views/themes/default/modules/sys/sysIndex/topMenuUser.html +++ b/modules/core/src/main/resources/views/themes/default/modules/sys/sysIndex/topMenuUser.html @@ -33,5 +33,20 @@ <% }else{ %>
  • <% } %> + <% if(user.roleList.~size > 0){ %> +
  • + <% var roleCode = @ObjectUtils.toStringIgnoreNull(session.roleCode, ''); %> + + <% for(var role in user.roleList){ %> +
  • + + ${role.roleName} + +
  • + <% } %> + <% } %> +
  • \ No newline at end of file