WANG 5 жил өмнө
parent
commit
fdad6b40a2

+ 18 - 12
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/StudentController.java

@@ -156,19 +156,22 @@ public class StudentController extends ControllerSupport {
 				predicates.add(cb.exists(subquery));
 			}
 
+			Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
+					accessUser.getRoleList(), OrgStudentData.CODE);
+			Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
+					accessUser.getRoleList(), AllStudentData.CODE);
 			// 学习中心角色用户数据过滤
 			if (hasRole(RoleMeta.LC_USER)) {
-				// 数据权限判断
-				Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
-						accessUser.getRoleList(), OrgStudentData.CODE);
-				Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
-						accessUser.getRoleList(), AllStudentData.CODE);
-				// 学习中心角色用户只能访问学习中心的学生数据
 				if ((!allStudentData) && orgStudentData) {
 					StudentCacheBean student = CacheHelper.getStudent(accessUser.getUserId());
 					Long orgId = student.getOrgId();
 					predicates.add(cb.equal(root.get("orgId"), orgId));
 				}
+			} else {
+				if (!allStudentData) {
+					// 查询不到数据
+					predicates.add(cb.equal(root.get("orgId"), -1));
+				}
 			}
 
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
@@ -281,19 +284,22 @@ public class StudentController extends ControllerSupport {
 				predicates.add(cb.exists(subquery));
 			}
 
+			Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
+					accessUser.getRoleList(), OrgStudentData.CODE);
+			Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
+					accessUser.getRoleList(), AllStudentData.CODE);
 			// 学习中心角色用户数据过滤
 			if (hasRole(RoleMeta.LC_USER)) {
-				// 数据权限判断
-				Boolean orgStudentData = PrivilegeManager.judge(finalRootOrgId,
-						accessUser.getRoleList(), OrgStudentData.CODE);
-				Boolean allStudentData = PrivilegeManager.judge(finalRootOrgId,
-						accessUser.getRoleList(), AllStudentData.CODE);
-				// 学习中心角色用户只能访问学习中心的学生数据
 				if ((!allStudentData) && orgStudentData) {
 					StudentCacheBean student = CacheHelper.getStudent(accessUser.getUserId());
 					Long orgId = student.getOrgId();
 					predicates.add(cb.equal(root.get("orgId"), orgId));
 				}
+			} else {
+				if (!allStudentData) {
+					// 查询不到数据
+					predicates.add(cb.equal(root.get("orgId"), -1));
+				}
 			}
 
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));