浏览代码

getStudentClientMenu

wangwei 5 年之前
父节点
当前提交
2edf1fe759

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

@@ -72,6 +72,8 @@ public class RolePrivilegeController extends ControllerSupport {
 			.asList(new String[]{"index_privilege_group_list", "index_app_list", "index_school",
 					"school_config", "index_school_privilege_settings", "system"});
 
+	private static final String STUDENT_CLIENT_MENU = "STUDENT_CLIENT_MENU";
+
 	@Autowired
 	PrivilegeGroupRepo privilegeGroupRepo;
 
@@ -252,49 +254,49 @@ public class RolePrivilegeController extends ControllerSupport {
 
 		return pList;
 	}
-	
+
 	/**
 	 * 2020年2月11日
 	 *
 	 * @author WANGWEI
 	 * @param rootOrgId
-	 * @param privilegeGroupCode
-	 * @param withRootOrgSuffix
-	 * @param full
 	 * @return
 	 */
-	@ApiOperation(value = "查询顶级机构的权限集合")
-	@GetMapping("getRootOrgPrivilegeList")
-	public List<PrivilegeDomain> getRootOrgPrivilegeList(@RequestParam Long rootOrgId,
-			@RequestParam String privilegeGroupCode,
-			@RequestParam(defaultValue = "true") boolean withRootOrgSuffix,
-			@RequestParam boolean full) {
-
-		validateRootOrgIsolation(rootOrgId);
+	@ApiOperation(value = "查询学生端菜单")
+	@GetMapping("getStudentClientMenu")
+	public List<PrivilegeDomain> getStudentClientMenu(
+			@RequestParam(required = false) Long rootOrgId) {
 
-		PrivilegeGroupEntity matrixPrivilegeGroup = null;
-		
-		if (withRootOrgSuffix) {
-			
-			matrixPrivilegeGroup = privilegeGroupRepo.findByCode(privilegeGroupCode);
-			if (null == matrixPrivilegeGroup) {
-				throw new StatusException("002109", "groupCode is not existing");
-			}
-			
-			privilegeGroupCode = privilegeGroupCode + "_" + rootOrgId;
+		if (null == rootOrgId) {
+			rootOrgId = getRootOrgId();
+		} else {
+			validateRootOrgIsolation(rootOrgId);
 		}
 
-		PrivilegeGroupEntity privilegeGroup = privilegeGroupRepo.findByCode(privilegeGroupCode);
+		String code = STUDENT_CLIENT_MENU + "_" + rootOrgId;
+
+		boolean undefined = false;
+
+		PrivilegeGroupEntity privilegeGroup = privilegeGroupRepo.findByCode(code);
 
 		if (null == privilegeGroup) {
-			throw new StatusException("002101", "groupCode is not existing");
+			privilegeGroup = privilegeGroupRepo.findByCode(STUDENT_CLIENT_MENU);
+			undefined = true;
+		} else {
+			if (null == privilegeGroup.getRootOrgId()) {
+				throw new StatusException("002101", "data error");
+			}
+			GlobalHelper.uniformRootOrg(rootOrgId, privilegeGroup.getRootOrgId());
 		}
 
-		List<RootOrgPrivilegeRelationEntity> list = rootOrgPrivilegeRelationRepo
-				.findAllByRootOrgIdAndGroupId(rootOrgId, privilegeGroup.getId());
+		List<Long> pList = null;
+		if (!undefined) {
+			List<RootOrgPrivilegeRelationEntity> list = rootOrgPrivilegeRelationRepo
+					.findAllByRootOrgIdAndGroupId(rootOrgId, privilegeGroup.getId());
 
-		List<Long> pList = list.stream().map(RootOrgPrivilegeRelationEntity::getPrivilegeId)
-				.collect(Collectors.toList());
+			pList = list.stream().map(RootOrgPrivilegeRelationEntity::getPrivilegeId)
+					.collect(Collectors.toList());
+		}
 
 		List<PrivilegeEntity> privilegeList = privilegeRepo
 				.findAllByGroupIdOrderByWeightDesc(privilegeGroup.getId());
@@ -302,9 +304,9 @@ public class RolePrivilegeController extends ControllerSupport {
 		List<PrivilegeDomain> privilegeInfoList = Lists.newArrayList();
 
 		for (PrivilegeEntity cur : privilegeList) {
-			boolean hasPrivilege = pList.contains(cur.getId());
+			boolean hasPrivilege = undefined ? true : pList.contains(cur.getId());
 
-			if ((!full) && (!hasPrivilege)) {
+			if (!hasPrivilege) {
 				continue;
 			}