|
@@ -1,8 +1,12 @@
|
|
|
package cn.com.qmth.examcloud.support.privilege;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.Role;
|
|
|
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.PrivilegeRolesCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.RootOrgPrivilegesCacheBean;
|
|
|
|
|
|
/**
|
|
|
* 权限管理器
|
|
@@ -23,6 +27,22 @@ public class PrivilegeManager {
|
|
|
* @return
|
|
|
*/
|
|
|
public static Boolean judge(Long rootOrgId, List<Role> roleList, String privilegeCode) {
|
|
|
+
|
|
|
+ PrivilegeRolesCacheBean cacheBean = CacheHelper.getPrivilegeRoles(rootOrgId, privilegeCode);
|
|
|
+ Set<Long> roleIdList = cacheBean.getRoleIdList();
|
|
|
+ Set<String> roleCodeList = cacheBean.getRoleCodeList();
|
|
|
+
|
|
|
+ for (Role cur : roleList) {
|
|
|
+ Long roleId = cur.getRoleId();
|
|
|
+ String roleCode = cur.getRoleCode();
|
|
|
+
|
|
|
+ if (null != roleId && roleIdList.contains(roleId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (null != roleCode && roleCodeList.contains(roleCode)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -35,6 +55,14 @@ public class PrivilegeManager {
|
|
|
* @return
|
|
|
*/
|
|
|
public static Boolean judge(Long rootOrgId, String privilegeCode) {
|
|
|
+
|
|
|
+ RootOrgPrivilegesCacheBean cacheBean = CacheHelper.getRootOrgPrivileges(rootOrgId);
|
|
|
+
|
|
|
+ Set<String> privilegeCodeList = cacheBean.getPrivilegeCodeList();
|
|
|
+ if (privilegeCodeList.contains(privilegeCode)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|