|
@@ -1,10 +1,12 @@
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.enums.CURD;
|
|
import cn.com.qmth.examcloud.api.commons.enums.CURD;
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
import cn.com.qmth.examcloud.api.commons.enums.ExamType;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.PageInfo;
|
|
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.bean.User;
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.UserType;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnum;
|
|
import cn.com.qmth.examcloud.commons.helpers.DynamicEnum;
|
|
@@ -14,7 +16,9 @@ import cn.com.qmth.examcloud.commons.util.*;
|
|
import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
|
|
import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.UserDataRuleCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.AddUserDataRuleReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
@@ -43,6 +47,7 @@ import cn.com.qmth.examcloud.task.api.request.SyncExamReq;
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
import cn.com.qmth.examcloud.web.config.SystemProperties;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
|
+import cn.com.qmth.examcloud.web.security.DataRule;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
@@ -54,10 +59,7 @@ import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.data.domain.Page;
|
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
|
-import org.springframework.data.domain.Pageable;
|
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
|
|
|
+import org.springframework.data.domain.*;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -132,6 +134,9 @@ public class ExamController extends ControllerSupport {
|
|
@Autowired
|
|
@Autowired
|
|
DataSyncCloudService dataSyncCloudService;
|
|
DataSyncCloudService dataSyncCloudService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ UserDataRuleCloudService userDataRuleCloudService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
ExamSettingsCache examSettingsCache;
|
|
ExamSettingsCache examSettingsCache;
|
|
|
|
|
|
@@ -225,18 +230,31 @@ public class ExamController extends ControllerSupport {
|
|
* @return
|
|
* @return
|
|
* @author WANGWEI
|
|
* @author WANGWEI
|
|
*/
|
|
*/
|
|
|
|
+ @DataRule(type = DataRuleType.EXAM)
|
|
@ApiOperation(value = "分页查询考试批次")
|
|
@ApiOperation(value = "分页查询考试批次")
|
|
@GetMapping("queryPage/{curPage}/{pageSize}")
|
|
@GetMapping("queryPage/{curPage}/{pageSize}")
|
|
public PageInfo<ExamDomain> queryPage(@PathVariable Integer curPage,
|
|
public PageInfo<ExamDomain> queryPage(@PathVariable Integer curPage,
|
|
- @PathVariable Integer pageSize, @RequestParam(required = false) String name,
|
|
|
|
|
|
+ @PathVariable Integer pageSize,
|
|
|
|
+ @RequestParam(required = false) String name,
|
|
@RequestParam(required = false) String examType,
|
|
@RequestParam(required = false) String examType,
|
|
@RequestParam(required = false) Boolean enable,
|
|
@RequestParam(required = false) Boolean enable,
|
|
@RequestParam(required = false) String propertyKeys) {
|
|
@RequestParam(required = false) String propertyKeys) {
|
|
-
|
|
|
|
User accessUser = getAccessUser();
|
|
User accessUser = getAccessUser();
|
|
|
|
|
|
|
|
+ PageRequest pageable = PageRequest.of(curPage, pageSize, new Sort(Direction.DESC, "updateTime", "id"));
|
|
|
|
+
|
|
|
|
+ UserDataRule userDataRule = super.getUserDataRule(DataRuleType.EXAM);
|
|
|
|
+ if (userDataRule.assertEmptyQueryResult()) {
|
|
|
|
+ return new PageInfo(new PageImpl<>(new ArrayList<>(), pageable, 0L));
|
|
|
|
+ }
|
|
|
|
+
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if (userDataRule.assertNeedQueryRefIds()) {
|
|
|
|
+ predicates.add(root.get("id").in(userDataRule.getRefIds()));
|
|
|
|
+ }
|
|
|
|
+
|
|
predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
|
|
predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
|
|
if (StringUtils.isNotBlank(name)) {
|
|
if (StringUtils.isNotBlank(name)) {
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
@@ -251,10 +269,7 @@ public class ExamController extends ControllerSupport {
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
};
|
|
};
|
|
|
|
|
|
- PageRequest pageRequest = PageRequest.of(curPage, pageSize,
|
|
|
|
- new Sort(Direction.DESC, "updateTime", "id"));
|
|
|
|
-
|
|
|
|
- Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
|
|
|
|
|
|
+ Page<ExamEntity> page = examRepo.findAll(specification, pageable);
|
|
|
|
|
|
Iterator<ExamEntity> iterator = page.iterator();
|
|
Iterator<ExamEntity> iterator = page.iterator();
|
|
List<ExamDomain> list = Lists.newArrayList();
|
|
List<ExamDomain> list = Lists.newArrayList();
|
|
@@ -293,7 +308,7 @@ public class ExamController extends ControllerSupport {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- PageInfo<ExamDomain> ret = new PageInfo<ExamDomain>(page, list);
|
|
|
|
|
|
+ PageInfo<ExamDomain> ret = new PageInfo<>(page, list);
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -307,6 +322,7 @@ public class ExamController extends ControllerSupport {
|
|
* @return
|
|
* @return
|
|
* @author WANGWEI
|
|
* @author WANGWEI
|
|
*/
|
|
*/
|
|
|
|
+ @DataRule(type = DataRuleType.EXAM)
|
|
@ApiOperation(value = "查询考试批次")
|
|
@ApiOperation(value = "查询考试批次")
|
|
@GetMapping("queryByNameLike")
|
|
@GetMapping("queryByNameLike")
|
|
public List<ExamDomain> query(@RequestParam(required = true) String name,
|
|
public List<ExamDomain> query(@RequestParam(required = true) String name,
|
|
@@ -315,14 +331,23 @@ public class ExamController extends ControllerSupport {
|
|
@RequestParam(required = false) String propertyKeys,
|
|
@RequestParam(required = false) String propertyKeys,
|
|
@RequestParam(required = false) Long studentId,
|
|
@RequestParam(required = false) Long studentId,
|
|
@RequestParam(required = false) Long rootOrgId) {
|
|
@RequestParam(required = false) Long rootOrgId) {
|
|
-
|
|
|
|
if (null == rootOrgId) {
|
|
if (null == rootOrgId) {
|
|
rootOrgId = getRootOrgId();
|
|
rootOrgId = getRootOrgId();
|
|
}
|
|
}
|
|
final Long finalRootOrgId = rootOrgId;
|
|
final Long finalRootOrgId = rootOrgId;
|
|
|
|
|
|
|
|
+ UserDataRule userDataRule = super.getUserDataRule(DataRuleType.EXAM);
|
|
|
|
+ if (userDataRule.assertEmptyQueryResult()) {
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
Specification<ExamEntity> specification = (root, query, cb) -> {
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if (userDataRule.assertNeedQueryRefIds()) {
|
|
|
|
+ predicates.add(root.get("id").in(userDataRule.getRefIds()));
|
|
|
|
+ }
|
|
|
|
+
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
predicates.add(cb.equal(root.get("rootOrgId"), finalRootOrgId));
|
|
if (StringUtils.isNotBlank(name)) {
|
|
if (StringUtils.isNotBlank(name)) {
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
|
|
@@ -541,6 +566,11 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
examSettingsCache.remove(saved.getId());
|
|
examSettingsCache.remove(saved.getId());
|
|
|
|
|
|
|
|
+ if (CURD.CREATION == es) {
|
|
|
|
+ // 用户与考试的数据权限
|
|
|
|
+ userDataRuleCloudService.addUserDataRule(new AddUserDataRuleReq(accessUser.getUserId(), DataRuleType.EXAM, saved.getId()));
|
|
|
|
+ }
|
|
|
|
+
|
|
return saved;
|
|
return saved;
|
|
}
|
|
}
|
|
|
|
|