|
@@ -18,13 +18,13 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
+import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Sets;
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.base.util.RegExpUtil;
|
|
import cn.com.qmth.examcloud.commons.base.util.RegExpUtil;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.tree.EleTreeNode;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.tree.EleTreeNode;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeUtil;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeUtil;
|
|
-import cn.com.qmth.examcloud.commons.web.security.bean.Role;
|
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupBean;
|
|
@@ -90,17 +90,7 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
throw new StatusException("B-002001", "groupCode is not existing");
|
|
throw new StatusException("B-002001", "groupCode is not existing");
|
|
}
|
|
}
|
|
|
|
|
|
- List<Role> roleList = accessUser.getRoleList();
|
|
|
|
- List<Long> roleIdList = Lists.newArrayList();
|
|
|
|
- for (Role cur : roleList) {
|
|
|
|
- String roleCode = cur.getRoleCode();
|
|
|
|
- cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity role = roleRepo
|
|
|
|
- .findByCode(roleCode);
|
|
|
|
- if (null == role) {
|
|
|
|
- throw new StatusException("B-002002", "role code is wrong. roleCode=" + roleCode);
|
|
|
|
- }
|
|
|
|
- roleIdList.add(role.getId());
|
|
|
|
- }
|
|
|
|
|
|
+ List<Long> roleIdList = getAccessUserRoleIdList();
|
|
|
|
|
|
List<RolePrivilegeRelationEntity> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
List<RolePrivilegeRelationEntity> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
.findAllByRoleIdInAndRootOrgId(roleIdList, rootOrgId);
|
|
.findAllByRoleIdInAndRootOrgId(roleIdList, rootOrgId);
|
|
@@ -304,13 +294,27 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
@ApiOperation(value = "校验权限")
|
|
@ApiOperation(value = "校验权限")
|
|
@PostMapping("checkPrivileges")
|
|
@PostMapping("checkPrivileges")
|
|
public Map<String, Boolean> checkPrivileges(@RequestParam String privilegeCodes) {
|
|
public Map<String, Boolean> checkPrivileges(@RequestParam String privilegeCodes) {
|
|
|
|
+
|
|
List<String> privilegeCodeList = RegExpUtil.findAll(privilegeCodes, "[0-9A-Za-z_]+");
|
|
List<String> privilegeCodeList = RegExpUtil.findAll(privilegeCodes, "[0-9A-Za-z_]+");
|
|
|
|
|
|
- for (String cur : privilegeCodeList) {
|
|
|
|
|
|
+ User accessUser = getAccessUser();
|
|
|
|
+
|
|
|
|
+ List<Long> roleIdList = getAccessUserRoleIdList();
|
|
|
|
|
|
|
|
+ List<PrivilegeEntity> PrivilegeEntityList = privilegeRepo
|
|
|
|
+ .findAllByCodeIn(privilegeCodeList);
|
|
|
|
+
|
|
|
|
+ Map<String, Boolean> ret = Maps.newHashMap();
|
|
|
|
+
|
|
|
|
+ for (PrivilegeEntity cur : PrivilegeEntityList) {
|
|
|
|
+ List<RolePrivilegeRelationEntity> relationEntityList = rolePrivilegeRelationRepo
|
|
|
|
+ .findAllByRoleIdInAndRootOrgIdAndPrivilegeId(roleIdList,
|
|
|
|
+ accessUser.getRootOrgId(), cur.getId());
|
|
|
|
+
|
|
|
|
+ ret.put(cur.getCode(), CollectionUtils.isNotEmpty(relationEntityList));
|
|
}
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|