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"; + +}