|
@@ -31,8 +31,9 @@ import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.RoleBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeDomain;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeGroupDomain;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.RoleDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UpdateRolePrivilegeRelationsDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.AppRepo;
|
|
@@ -47,6 +48,8 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.PrivilegeGroupEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.RolePrivilegeRelationEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.RolePrivilegeService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.bean.RoleInfo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
@@ -56,6 +59,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
* @date 2018年6月12日
|
|
|
* @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
*/
|
|
|
+@Api("角色权限")
|
|
|
@Transactional
|
|
|
@RestController
|
|
|
@RequestMapping("${$rmp.ctr.basic}/rolePrivilege")
|
|
@@ -366,4 +370,66 @@ public class RolePrivilegeController extends ControllerSupport {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "添加角色")
|
|
|
+ @PostMapping("addRole")
|
|
|
+ public RoleEntity addRole(@RequestBody RoleDomain req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String code = req.getCode();
|
|
|
+ String name = req.getName();
|
|
|
+
|
|
|
+ validateRootOrgIsolation(rootOrgId);
|
|
|
+
|
|
|
+ RoleEntity roleByCode = roleRepo.findByCode(code);
|
|
|
+ if (null != roleByCode) {
|
|
|
+ throw new StatusException("B-620001", "角色编码已被占用");
|
|
|
+ }
|
|
|
+
|
|
|
+ RoleEntity roleByName = roleRepo.findByNameAndRootOrgId(name, rootOrgId);
|
|
|
+ if (null != roleByName) {
|
|
|
+ throw new StatusException("B-620002", "角色名称已被占用");
|
|
|
+ }
|
|
|
+
|
|
|
+ RoleInfo info = new RoleInfo();
|
|
|
+ info.setCode(code);
|
|
|
+ info.setName(name);
|
|
|
+ info.setRootOrgId(rootOrgId);
|
|
|
+
|
|
|
+ RoleEntity saved = rolePrivilegeService.saveRole(info);
|
|
|
+
|
|
|
+ return saved;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "更新角色")
|
|
|
+ @PutMapping("updateRole")
|
|
|
+ public RoleEntity updateRole(@RequestBody RoleDomain req) {
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String code = req.getCode();
|
|
|
+ String name = req.getName();
|
|
|
+
|
|
|
+ validateRootOrgIsolation(rootOrgId);
|
|
|
+
|
|
|
+ RoleInfo info = new RoleInfo();
|
|
|
+ info.setCode(code);
|
|
|
+ info.setName(name);
|
|
|
+ info.setRootOrgId(rootOrgId);
|
|
|
+
|
|
|
+ RoleEntity saved = rolePrivilegeService.saveRole(info);
|
|
|
+
|
|
|
+ return saved;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除角色")
|
|
|
+ @DeleteMapping("deleteRole/{roleId}")
|
|
|
+ public RoleEntity deleteRole(@PathVariable Long roleId) {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+
|
|
|
+ RoleInfo info = new RoleInfo();
|
|
|
+ info.setId(roleId);
|
|
|
+ info.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+
|
|
|
+ RoleEntity saved = rolePrivilegeService.deleteRole(info, false);
|
|
|
+
|
|
|
+ return saved;
|
|
|
+ }
|
|
|
+
|
|
|
}
|