WANG 5 жил өмнө
parent
commit
00c65b987a

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

@@ -33,6 +33,7 @@ import com.google.common.collect.Lists;
 import cn.com.qmth.examcloud.api.commons.enums.BooleanSelect;
 import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.api.commons.security.enums.RoleMeta;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
 import cn.com.qmth.examcloud.core.basic.api.controller.bean.StudentDomain;
@@ -48,6 +49,11 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.StudentEntity;
 import cn.com.qmth.examcloud.core.basic.service.StudentService;
 import cn.com.qmth.examcloud.core.basic.service.bean.StudentInfo;
 import cn.com.qmth.examcloud.core.basic.service.cache.StudentCache;
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
+import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
+import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine.DataAccess.ExamWorkData.StudentInfoData.AllStudentData;
+import cn.com.qmth.examcloud.support.privilege.PrivilegeDefine.DataAccess.ExamWorkData.StudentInfoData.OrgStudentData;
+import cn.com.qmth.examcloud.support.privilege.PrivilegeManager;
 import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
 import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
 import cn.com.qmth.examcloud.web.config.SystemConfig;
@@ -149,6 +155,22 @@ public class StudentController extends ControllerSupport {
 				subquery.where(cb.and(p1, p2));
 				predicates.add(cb.exists(subquery));
 			}
+
+			// 学习中心角色用户数据过滤
+			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));
+				}
+			}
+
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};
 
@@ -259,6 +281,21 @@ public class StudentController extends ControllerSupport {
 				predicates.add(cb.exists(subquery));
 			}
 
+			// 学习中心角色用户数据过滤
+			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));
+				}
+			}
+
 			return cb.and(predicates.toArray(new Predicate[predicates.size()]));
 		};