wangwei 7 years ago
parent
commit
c95e835298

+ 25 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/RolePrivilegeController.java

@@ -27,7 +27,9 @@ 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.TreeUtil;
 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.PrivilegeGroupBean;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.PrivilegeInfo;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.UpdateRolePrivilegeRelationsReq;
@@ -80,6 +82,29 @@ public class RolePrivilegeController extends ControllerSupport {
 	@Autowired
 	RolePrivilegeService rolePrivilegeService;
 
+	@ApiOperation(value = "查询所有角色", notes = "")
+	@PostMapping("getAllRoles")
+	public List<RoleBean> getAllRoles(@RequestParam Boolean withSuperAdmin) {
+		List<cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity> roleList = roleRepo.findAll();
+		List<RoleBean> roleBeanList = Lists.newArrayList();
+
+		for (cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity cur : roleList) {
+
+			if ((!withSuperAdmin) && cur.getCode().equals(RoleMeta.SUPER_ADMIN.name())) {
+				continue;
+			}
+
+			RoleBean bean = new RoleBean();
+			bean.setRoleId(cur.getId());
+			bean.setRoleName(cur.getName());
+			bean.setRoleCode(cur.getCode());
+
+			roleBeanList.add(bean);
+		}
+
+		return roleBeanList;
+	}
+
 	@ApiOperation(value = "查询用户的权限树", notes = "")
 	@PostMapping("getUserPrivileges")
 	public List<PrivilegeInfo> getPrivileges(@RequestParam String groupCode,