|
@@ -34,10 +34,10 @@ 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.RoleRepo;
|
|
|
-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 cn.com.qmth.examcloud.core.basic.dao.entity.AppEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroupEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.RolePrivilegeService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
@@ -81,7 +81,7 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
User accessUser = getAccessUser();
|
|
|
Long rootOrgId = accessUser.getRootOrgId();
|
|
|
|
|
|
- PrivilegeGroup privilegeGroup = privilegeGroupRepo.findByCode(groupCode);
|
|
|
+ PrivilegeGroupEntity privilegeGroup = privilegeGroupRepo.findByCode(groupCode);
|
|
|
|
|
|
if (null == privilegeGroup) {
|
|
|
throw new StatusException("B-002001", "groupCode is not existing");
|
|
@@ -91,26 +91,26 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
List<Long> roleIdList = Lists.newArrayList();
|
|
|
for (Role cur : roleList) {
|
|
|
String roleCode = cur.getRoleCode();
|
|
|
- cn.com.qmth.examcloud.core.basic.dao.entity.Role role = roleRepo.findByCode(roleCode);
|
|
|
+ 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<RolePrivilegeRelation> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
|
+ List<RolePrivilegeRelationEntity> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
|
.findAllByRoleIdInAndRootOrgId(roleIdList, rootOrgId);
|
|
|
|
|
|
Set<String> pIdSet = Sets.newHashSet();
|
|
|
- for (RolePrivilegeRelation cur : rolePrivRelationList) {
|
|
|
+ for (RolePrivilegeRelationEntity cur : rolePrivRelationList) {
|
|
|
pIdSet.add(String.valueOf(cur.getPrivilegeId()));
|
|
|
}
|
|
|
|
|
|
- List<Privilege> privilegeList = privilegeRepo.findAllByGroupId(privilegeGroup.getId());
|
|
|
+ List<PrivilegeEntity> privilegeList = privilegeRepo.findAllByGroupId(privilegeGroup.getId());
|
|
|
|
|
|
List<PrivilegeInfo> privilegeInfoList = Lists.newArrayList();
|
|
|
|
|
|
- for (Privilege cur : privilegeList) {
|
|
|
+ for (PrivilegeEntity cur : privilegeList) {
|
|
|
boolean hasPrivilege = pIdSet.contains(String.valueOf(cur.getId()));
|
|
|
if ((!full) && (!hasPrivilege)) {
|
|
|
continue;
|
|
@@ -143,15 +143,15 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
@GetMapping("getPrivilegeGroupList")
|
|
|
public List<PrivilegeGroupBean> getPrivilegeGroupList() {
|
|
|
Sort sort = new Sort(Sort.Direction.ASC, "id");
|
|
|
- List<PrivilegeGroup> list = privilegeGroupRepo.findAll(sort);
|
|
|
+ List<PrivilegeGroupEntity> list = privilegeGroupRepo.findAll(sort);
|
|
|
|
|
|
List<PrivilegeGroupBean> ret = Lists.newArrayList();
|
|
|
|
|
|
- for (PrivilegeGroup cur : list) {
|
|
|
+ for (PrivilegeGroupEntity cur : list) {
|
|
|
PrivilegeGroupBean bean = new PrivilegeGroupBean();
|
|
|
bean.setId(cur.getId());
|
|
|
bean.setAppId(cur.getAppId());
|
|
|
- App app = appRepo.findOne(cur.getAppId());
|
|
|
+ AppEntity app = appRepo.findOne(cur.getAppId());
|
|
|
if (null != app) {
|
|
|
bean.setAppName(app.getName());
|
|
|
}
|
|
@@ -167,8 +167,8 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
@ApiOperation(value = "查询权限树")
|
|
|
@GetMapping("getPrivilegeTree/{groupId}")
|
|
|
public EleTreeNode getPrivilegeTree(@PathVariable Long groupId) {
|
|
|
- PrivilegeGroup group = privilegeGroupRepo.findOne(groupId);
|
|
|
- List<Privilege> privilegeList = privilegeRepo.findAllByGroupId(groupId);
|
|
|
+ PrivilegeGroupEntity group = privilegeGroupRepo.findOne(groupId);
|
|
|
+ List<PrivilegeEntity> privilegeList = privilegeRepo.findAllByGroupId(groupId);
|
|
|
EleTreeNode rootNode = new EleTreeNode(-1L, group.getName());
|
|
|
TreeUtil.convert2OneEleTreeNode(rootNode, privilegeList);
|
|
|
|
|
@@ -178,11 +178,11 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
@ApiOperation(value = "查询权限ID集合")
|
|
|
@GetMapping("getPrivilegeIdList/{rootOrgId}/{roleId}")
|
|
|
public Set<Long> getPrivilegeTree(@PathVariable Long rootOrgId, @PathVariable Long roleId) {
|
|
|
- List<RolePrivilegeRelation> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
|
+ List<RolePrivilegeRelationEntity> rolePrivRelationList = rolePrivilegeRelationRepo
|
|
|
.findAllByRoleIdAndRootOrgId(roleId, rootOrgId);
|
|
|
|
|
|
Set<Long> pIdSet = Sets.newHashSet();
|
|
|
- for (RolePrivilegeRelation cur : rolePrivRelationList) {
|
|
|
+ for (RolePrivilegeRelationEntity cur : rolePrivRelationList) {
|
|
|
pIdSet.add(cur.getPrivilegeId());
|
|
|
}
|
|
|
|
|
@@ -207,19 +207,19 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "增加权限")
|
|
|
@PostMapping("addPrivilege")
|
|
|
- public Privilege addPrivilege(@RequestBody Privilege privilege) {
|
|
|
+ public PrivilegeEntity addPrivilege(@RequestBody PrivilegeEntity privilege) {
|
|
|
|
|
|
privilege.setName(privilege.getName().trim());
|
|
|
privilege.setCode(privilege.getCode().trim());
|
|
|
privilege.setDescription(privilege.getDescription());
|
|
|
|
|
|
- PrivilegeGroup group = privilegeGroupRepo.findOne(privilege.getGroupId());
|
|
|
+ PrivilegeGroupEntity group = privilegeGroupRepo.findOne(privilege.getGroupId());
|
|
|
if (null == group) {
|
|
|
throw new StatusException("B-020001", "权限组不存在");
|
|
|
}
|
|
|
|
|
|
if (null != privilege.getParentId()) {
|
|
|
- Privilege parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
|
|
|
+ PrivilegeEntity parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
|
|
|
if (null == parentPrivilege) {
|
|
|
throw new StatusException("B-020002", "父权限不存在");
|
|
|
}
|
|
@@ -228,25 +228,25 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Privilege ret = privilegeRepo.save(privilege);
|
|
|
+ PrivilegeEntity ret = privilegeRepo.save(privilege);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "更新权限")
|
|
|
@PutMapping("updatePrivilege")
|
|
|
- public Privilege updatePrivilege(@RequestBody Privilege privilege) {
|
|
|
+ public PrivilegeEntity updatePrivilege(@RequestBody PrivilegeEntity privilege) {
|
|
|
|
|
|
privilege.setName(privilege.getName().trim());
|
|
|
privilege.setCode(privilege.getCode().trim());
|
|
|
privilege.setDescription(privilege.getDescription());
|
|
|
- PrivilegeGroup group = privilegeGroupRepo.findOne(privilege.getGroupId());
|
|
|
+ PrivilegeGroupEntity group = privilegeGroupRepo.findOne(privilege.getGroupId());
|
|
|
if (null == group) {
|
|
|
throw new StatusException("B-020001", "权限组不存在");
|
|
|
}
|
|
|
|
|
|
if (null != privilege.getParentId()) {
|
|
|
- Privilege parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
|
|
|
+ PrivilegeEntity parentPrivilege = privilegeRepo.findOne(privilege.getParentId());
|
|
|
if (null == parentPrivilege) {
|
|
|
throw new StatusException("B-020002", "父权限不存在");
|
|
|
}
|
|
@@ -255,7 +255,7 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Privilege ret = privilegeRepo.save(privilege);
|
|
|
+ PrivilegeEntity ret = privilegeRepo.save(privilege);
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -263,12 +263,12 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
@ApiOperation(value = "删除权限")
|
|
|
@DeleteMapping("deletePrivilege/{id}")
|
|
|
public void deletePrivilege(@PathVariable Long id) {
|
|
|
- Privilege privilege = privilegeRepo.findOne(id);
|
|
|
+ PrivilegeEntity privilege = privilegeRepo.findOne(id);
|
|
|
if (null == privilege) {
|
|
|
throw new StatusException("B-020004", "权限不存在");
|
|
|
}
|
|
|
|
|
|
- List<Privilege> children = privilegeRepo.findAllByParentId(privilege.getId());
|
|
|
+ List<PrivilegeEntity> children = privilegeRepo.findAllByParentId(privilege.getId());
|
|
|
if (CollectionUtils.isNotEmpty(children)) {
|
|
|
throw new StatusException("B-020005", "存在子权限");
|
|
|
}
|
|
@@ -277,8 +277,8 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "查询权限")
|
|
|
@GetMapping("getPrivilege/{id}")
|
|
|
- public Privilege getPrivilege(@PathVariable Long id) {
|
|
|
- Privilege privilege = privilegeRepo.findOne(id);
|
|
|
+ public PrivilegeEntity getPrivilege(@PathVariable Long id) {
|
|
|
+ PrivilegeEntity privilege = privilegeRepo.findOne(id);
|
|
|
if (null == privilege) {
|
|
|
throw new StatusException("B-020004", "权限不存在");
|
|
|
}
|