From a25aaf417bb12ded2c360531973b5d9bab68dfa8 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Sat, 23 Mar 2019 11:24:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lq/code/interceptor/shiro/ShiroRealm.java | 8 +++-- src/main/java/com/lq/code/util/Constant.java | 36 +++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/lq/code/util/Constant.java diff --git a/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java b/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java index 7439731..358c04e 100755 --- a/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java +++ b/src/main/java/com/lq/code/interceptor/shiro/ShiroRealm.java @@ -4,6 +4,7 @@ import com.lq.cms.service.SysRoleResourcePermissionService; import com.lq.cms.service.SysRoleService; import com.lq.cms.service.SysUserService; import com.lq.cms.vo.PermissionVo; +import com.lq.code.util.Constant; import com.lq.code.util.StringUtil; import com.lq.entity.SysRole; import com.lq.entity.SysUser; @@ -23,6 +24,7 @@ import java.util.List; */ public class ShiroRealm extends AuthorizingRealm { + @Autowired private SysUserService sysUserService; @Autowired @@ -50,16 +52,16 @@ public class ShiroRealm extends AuthorizingRealm { info.addRole(sysRoleName); List list = null; //admin默认获取全部权限 - if (StringUtil.isNotNull(sysRoleName)&&"admin".equals(sysRoleName)){ + if (StringUtil.isNotNull(sysRoleName)&& Constant.ROLE_ADMIN.equals(sysRoleName)){ list = sysRoleResourcePermissionService.findAllPermissonVo(); }else { list = sysRoleResourcePermissionService.findByRoleId(sysRole.getId()); } //每个角色拥有的权限 for (PermissionVo vo:list){ - info.addStringPermission(vo.getMenuUrl()+":"+vo.getPermissionName()); + info.addStringPermission(vo.getMenuUrl()+Constant.PERSSION_MARK+vo.getPermissionName()); } - if ("admin".equals(sysRoleName)){ + if (Constant.ROLE_ADMIN.equals(sysRoleName)){ break; } diff --git a/src/main/java/com/lq/code/util/Constant.java b/src/main/java/com/lq/code/util/Constant.java new file mode 100644 index 0000000..047b356 --- /dev/null +++ b/src/main/java/com/lq/code/util/Constant.java @@ -0,0 +1,36 @@ +package com.lq.code.util; + +/** + * @Author: qi + * @Description: + * @Date: Create in 11:20 AM 2019/3/23 + */ +public interface Constant { + + /** + * 权限-新增 + */ + String PERMISSION_INSERT = "INSERT"; + /** + * 权限-更新 + */ + String PERMISSION_UPDATE = "UPDATE"; + /** + * 权限-查询 + */ + String PERMISSION_SELECT="SELECT"; + /** + * 权限-删除 + */ + String PERMISSION_DELETE = "DELETE"; + + /** + * 权限-描述切割符号 + */ + String PERSSION_MARK = ":"; + /** + * 超级管理员 + */ + String ROLE_ADMIN = "admin"; + +}