|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.controller;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.helpers.tree.EleTreeNode;
|
|
@@ -25,21 +27,23 @@ import cn.com.qmth.examcloud.core.basic.dao.AppRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.PrivilegeGroupRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.PrivilegeRepo;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.RolePrivilegeRelationRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.App;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Privilege;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroup;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelation;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
|
- * 权限
|
|
|
+ * 角色权限
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
* @date 2018年6月12日
|
|
|
* @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("${app.api.root}/privilege")
|
|
|
-public class PrivilegeController extends ControllerSupport {
|
|
|
+@RequestMapping("${app.api.root}/rolePrivilege")
|
|
|
+public class RolePrivilegeController extends ControllerSupport {
|
|
|
|
|
|
@Autowired
|
|
|
AppRepo appRepo;
|
|
@@ -53,6 +57,9 @@ public class PrivilegeController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
OrgRepo orgRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RolePrivilegeRelationRepo rolePrivilegeRelationRepo;
|
|
|
+
|
|
|
@ApiOperation(value = "查询权限组")
|
|
|
@GetMapping("getPrivilegeGroupList")
|
|
|
public List<PrivilegeGroupBean> getPrivilegeGroupList() {
|
|
@@ -89,6 +96,20 @@ public class PrivilegeController extends ControllerSupport {
|
|
|
return rootNode;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "查询权限ID集合")
|
|
|
+ @GetMapping("getPrivilegeIdList/{rootOrgId}/{roleId}")
|
|
|
+ public Set<Long> getPrivilegeTree(@PathVariable Long rootOrgId, @PathVariable Long roleId) {
|
|
|
+ List<RolePrivilegeRelation> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
|
+ .findAllByRoleIdAndRootOrgId(roleId, rootOrgId);
|
|
|
+
|
|
|
+ Set<Long> pIdSet = Sets.newHashSet();
|
|
|
+ for (RolePrivilegeRelation cur : rolePrivRelationList) {
|
|
|
+ pIdSet.add(cur.getPrivilegeId());
|
|
|
+ }
|
|
|
+
|
|
|
+ return pIdSet;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "增加权限")
|
|
|
@PostMapping("addPrivilege")
|
|
|
public Privilege addPrivilege(@RequestBody Privilege privilege) {
|