wangwei 7 years ago
parent
commit
b8702f359a

+ 9 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/provider/RolePrivilegeCloudServiceProvider.java

@@ -5,10 +5,12 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.google.common.collect.Lists;
 
+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.RolePrivilegeCloudService;
 import cn.com.qmth.examcloud.core.basic.api.bean.RoleBean;
@@ -48,10 +50,16 @@ public class RolePrivilegeCloudServiceProvider extends ControllerSupport
 	@ApiOperation(value = "查询所有角色", notes = "")
 	@PostMapping("getAllRoles")
 	@Override
-	public List<RoleBean> 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.getCode())) {
+				continue;
+			}
+
 			RoleBean bean = new RoleBean();
 			bean.setRoleId(cur.getId());
 			bean.setRoleName(cur.getName());

+ 1 - 1
examcloud-core-basic-api/src/main/java/cn/com/qmth/examcloud/core/basic/api/RolePrivilegeCloudService.java

@@ -19,6 +19,6 @@ public interface RolePrivilegeCloudService extends CloudService {
 	 * @author WANGWEI
 	 * @return
 	 */
-	List<RoleBean> getAllRoles();
+	List<RoleBean> getAllRoles(Boolean withSuperAdmin);
 
 }