|
@@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.PrivilegeGroupType;
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
@@ -51,6 +52,7 @@ import cn.com.qmth.examcloud.core.basic.service.bean.RoleInfo;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.helpers.tree.EleTreeNode;
|
|
|
import cn.com.qmth.examcloud.web.helpers.tree.TreeUtil;
|
|
|
+import cn.com.qmth.examcloud.web.interceptor.GlobalSequenceLock;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -196,7 +198,7 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
@ApiOperation(value = "查询权限组")
|
|
|
@GetMapping("getPrivilegeGroupList")
|
|
|
public List<PrivilegeGroupDomain> getPrivilegeGroupList() {
|
|
|
-
|
|
|
+
|
|
|
List<PrivilegeGroupEntity> list = privilegeGroupRepo.findAllByRootOrgIdIsNullOrderById();
|
|
|
|
|
|
List<PrivilegeGroupDomain> ret = Lists.newArrayList();
|
|
@@ -254,6 +256,101 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
return pList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2020年2月19日
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param groupId
|
|
|
+ * @param includeDisabledCodes
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "查询菜单树")
|
|
|
+ @GetMapping("getStudentClientMenuTree/{rootOrgId}")
|
|
|
+ @GlobalSequenceLock
|
|
|
+ @Transactional
|
|
|
+ public EleTreeNode getStudentClientMenuTree(@PathVariable Long rootOrgId,
|
|
|
+ @RequestParam(required = false) Boolean includeDisabledCodes) {
|
|
|
+
|
|
|
+ PrivilegeGroupEntity group = privilegeGroupRepo.findByRootOrgIdAndType(rootOrgId,
|
|
|
+ PrivilegeGroupType.STUDENT_CLIENT_MENU);
|
|
|
+
|
|
|
+ if (null == group) {
|
|
|
+ PrivilegeGroupEntity globalGroup = privilegeGroupRepo.findByCode(STUDENT_CLIENT_MENU);
|
|
|
+
|
|
|
+ group = new PrivilegeGroupEntity();
|
|
|
+ group.setCode(STUDENT_CLIENT_MENU + "_" + rootOrgId);
|
|
|
+ group.setName(globalGroup.getName());
|
|
|
+ group.setRootOrgId(rootOrgId);
|
|
|
+ group.setType(PrivilegeGroupType.STUDENT_CLIENT_MENU);
|
|
|
+
|
|
|
+ group.setExt1(globalGroup.getExt1());
|
|
|
+ group.setExt2(globalGroup.getExt2());
|
|
|
+ group.setExt3(globalGroup.getExt3());
|
|
|
+ group.setExt4(globalGroup.getExt4());
|
|
|
+ group.setExt5(globalGroup.getExt5());
|
|
|
+
|
|
|
+ group = privilegeGroupRepo.save(group);
|
|
|
+
|
|
|
+ List<PrivilegeEntity> globalPrivilegeList = privilegeRepo
|
|
|
+ .findAllByGroupIdOrderByWeightDesc(globalGroup.getId());
|
|
|
+ Map<Long, Integer> idIndex = Maps.newHashMap();
|
|
|
+ List<PrivilegeEntity> privilegeList = Lists.newArrayList();
|
|
|
+ Set<Long> privilegeIdSet = Sets.newHashSet();
|
|
|
+ int c = 0;
|
|
|
+ for (PrivilegeEntity cur : globalPrivilegeList) {
|
|
|
+ idIndex.put(cur.getId(), c);
|
|
|
+ c++;
|
|
|
+
|
|
|
+ PrivilegeEntity privilegeEntity = new PrivilegeEntity();
|
|
|
+ privilegeEntity.setCode(cur.getCode() + "_" + rootOrgId);
|
|
|
+ privilegeEntity.setDescription(cur.getDescription());
|
|
|
+ privilegeEntity.setGroupId(group.getId());
|
|
|
+ privilegeEntity.setName(cur.getName());
|
|
|
+ privilegeEntity.setWeight(cur.getWeight());
|
|
|
+
|
|
|
+ privilegeEntity.setExt1(cur.getExt1());
|
|
|
+ privilegeEntity.setExt2(cur.getExt2());
|
|
|
+ privilegeEntity.setExt3(cur.getExt3());
|
|
|
+ privilegeEntity.setExt4(cur.getExt4());
|
|
|
+ privilegeEntity.setExt5(cur.getExt5());
|
|
|
+
|
|
|
+ PrivilegeEntity saved = privilegeRepo.save(privilegeEntity);
|
|
|
+ privilegeList.add(saved);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < globalPrivilegeList.size(); i++) {
|
|
|
+ PrivilegeEntity p = privilegeList.get(i);
|
|
|
+ if (null == p.getParentId()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer j = idIndex.get(globalPrivilegeList.get(i).getId());
|
|
|
+ p.setParentId(privilegeList.get(j).getId());
|
|
|
+ privilegeRepo.save(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ rolePrivilegeService.updateRootOrgPrivilegeRelations(rootOrgId, group.getId(),
|
|
|
+ privilegeIdSet);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PrivilegeEntity> privilegeList = privilegeRepo
|
|
|
+ .findAllByGroupIdOrderByWeightDesc(group.getId());
|
|
|
+
|
|
|
+ EleTreeNode rootNode = new EleTreeNode(BasicConsts.ROOT_PRIVILEGE_ID, group.getName());
|
|
|
+
|
|
|
+ if (null != includeDisabledCodes && includeDisabledCodes) {
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ throw new StatusException("012001", "非法请求");
|
|
|
+ }
|
|
|
+ TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList, Lists.newArrayList());
|
|
|
+ } else {
|
|
|
+ TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList, disabledPrivilegeCodeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return rootNode;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 2020年2月11日
|
|
|
*
|
|
@@ -466,9 +563,36 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- PrivilegeEntity ret = privilegeRepo.save(privilege);
|
|
|
+ privilege = privilegeRepo.save(privilege);
|
|
|
|
|
|
- return ret;
|
|
|
+ if (group.getType().equals(PrivilegeGroupType.STUDENT_CLIENT_MENU)
|
|
|
+ && group.getCode().equals(STUDENT_CLIENT_MENU)) {
|
|
|
+
|
|
|
+ List<PrivilegeGroupEntity> gList = privilegeGroupRepo
|
|
|
+ .findAllByType(PrivilegeGroupType.STUDENT_CLIENT_MENU);
|
|
|
+
|
|
|
+ for (PrivilegeGroupEntity cur : gList) {
|
|
|
+ if (null == cur.getRootOrgId()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PrivilegeEntity p = privilegeRepo
|
|
|
+ .findByCode(privilege.getCode() + "_" + cur.getRootOrgId());
|
|
|
+ if (null != p) {
|
|
|
+ p.setDescription(privilege.getDescription());
|
|
|
+
|
|
|
+ p.setExt1(privilege.getExt1());
|
|
|
+ p.setExt2(privilege.getExt2());
|
|
|
+ p.setExt3(privilege.getExt3());
|
|
|
+ p.setExt4(privilege.getExt4());
|
|
|
+ p.setExt5(privilege.getExt5());
|
|
|
+
|
|
|
+ privilegeRepo.save(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return privilege;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除权限")
|
|
@@ -488,6 +612,30 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
|
|
|
privilegeRepo.deleteById(id);
|
|
|
rolePrivilegeRelationRepo.deleteByPrivilegeId(id);
|
|
|
+
|
|
|
+ PrivilegeGroupEntity groupEntity = GlobalHelper.getPresentEntity(privilegeGroupRepo,
|
|
|
+ privilege.getGroupId(), PrivilegeGroupEntity.class);
|
|
|
+
|
|
|
+ if (groupEntity.getType().equals(PrivilegeGroupType.STUDENT_CLIENT_MENU)
|
|
|
+ && groupEntity.getCode().equals(STUDENT_CLIENT_MENU)) {
|
|
|
+
|
|
|
+ List<PrivilegeGroupEntity> gList = privilegeGroupRepo
|
|
|
+ .findAllByType(PrivilegeGroupType.STUDENT_CLIENT_MENU);
|
|
|
+
|
|
|
+ for (PrivilegeGroupEntity cur : gList) {
|
|
|
+ if (null == cur.getRootOrgId()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ PrivilegeEntity p = privilegeRepo
|
|
|
+ .findByCode(privilege.getCode() + "_" + cur.getRootOrgId());
|
|
|
+ if (null != p) {
|
|
|
+ privilegeRepo.deleteById(p.getId());
|
|
|
+ rolePrivilegeRelationRepo.deleteByPrivilegeId(p.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "查询权限")
|