|
@@ -179,24 +179,23 @@ public class ExamController extends ControllerSupport {
|
|
|
@ApiOperation(value = "查询考试的课程集合")
|
|
|
@GetMapping("queryExamCourseList")
|
|
|
public List<ExamCourseRelationEntity> getExamCourseList(
|
|
|
- @RequestParam(required = true) Long examId, @RequestParam(required = false) String name,
|
|
|
+ @RequestParam(required = true) Long examId,
|
|
|
+ @RequestParam(required = false) String name,
|
|
|
@RequestParam(required = false) String level,
|
|
|
@RequestParam(required = false) Boolean enable) {
|
|
|
|
|
|
ExamEntity one = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
|
|
|
if (null == one) {
|
|
|
- throw new StatusException("001250", "examId is wrong");
|
|
|
+ throw new StatusException("001250", "考试不存在(" + examId + ")!");
|
|
|
}
|
|
|
validateRootOrgIsolation(one.getRootOrgId());
|
|
|
|
|
|
Specification<ExamCourseRelationEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
-
|
|
|
predicates.add(cb.equal(root.get("examId"), examId));
|
|
|
|
|
|
Predicate pr1 = cb.like(root.get("courseName"), toSqlSearchPattern(name));
|
|
|
Predicate pr2 = cb.like(root.get("courseCode"), toSqlSearchPattern(name));
|
|
|
-
|
|
|
predicates.add(cb.or(pr1, pr2));
|
|
|
|
|
|
if (StringUtils.isNotBlank(level)) {
|
|
@@ -212,19 +211,8 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
PageRequest pageRequest = PageRequest.of(0, 50, Sort.by(Direction.DESC, "updateTime"));
|
|
|
|
|
|
- Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification,
|
|
|
- pageRequest);
|
|
|
-
|
|
|
- Iterator<ExamCourseRelationEntity> iterator = page.iterator();
|
|
|
- List<ExamCourseRelationEntity> list = Lists.newArrayList();
|
|
|
-
|
|
|
- while (iterator.hasNext()) {
|
|
|
- ExamCourseRelationEntity next = iterator.next();
|
|
|
- list.add(next);
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
-
|
|
|
+ Page<ExamCourseRelationEntity> page = examCourseRelationRepo.findAll(specification, pageRequest);
|
|
|
+ return page.getContent();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -248,7 +236,6 @@ public class ExamController extends ControllerSupport {
|
|
|
@RequestParam(required = false) Boolean enable,
|
|
|
@RequestParam(required = false) String propertyKeys) {
|
|
|
User accessUser = getAccessUser();
|
|
|
-
|
|
|
PageRequest pageable = PageRequest.of(curPage, pageSize, Sort.by(Direction.DESC, "updateTime", "id"));
|
|
|
|
|
|
UserDataRule userDataRule = super.getUserDataRule(DataRuleType.EXAM);
|
|
@@ -279,14 +266,20 @@ public class ExamController extends ControllerSupport {
|
|
|
|
|
|
Page<ExamEntity> page = examRepo.findAll(specification, pageable);
|
|
|
|
|
|
- Iterator<ExamEntity> iterator = page.iterator();
|
|
|
- List<ExamDomain> list = Lists.newArrayList();
|
|
|
-
|
|
|
+ // 补充查询考试的属性值
|
|
|
List<String> propertyKeyList = null;
|
|
|
if (StringUtils.isNotBlank(propertyKeys)) {
|
|
|
propertyKeyList = RegExpUtil.findAll(propertyKeys, "\\w+");
|
|
|
}
|
|
|
+ if (propertyKeyList == null) {
|
|
|
+ propertyKeyList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ propertyKeyList.add(ExamProperties.IP_LIMIT.name());
|
|
|
+ propertyKeyList.add(ExamProperties.WEIXIN_ANSWER_ENABLED.name());
|
|
|
|
|
|
+
|
|
|
+ Iterator<ExamEntity> iterator = page.iterator();
|
|
|
+ List<ExamDomain> list = Lists.newArrayList();
|
|
|
while (iterator.hasNext()) {
|
|
|
ExamEntity next = iterator.next();
|
|
|
ExamDomain bean = new ExamDomain();
|
|
@@ -310,21 +303,15 @@ public class ExamController extends ControllerSupport {
|
|
|
bean.setSpecialSettingsEnabled(next.getSpecialSettingsEnabled());
|
|
|
bean.setSpecialSettingsType(next.getSpecialSettingsType());
|
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(propertyKeyList)) {
|
|
|
- Map<String, String> properties = getProperties(bean.getId(), propertyKeyList);
|
|
|
- bean.setProperties(properties);
|
|
|
- }
|
|
|
-
|
|
|
- DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
- DynamicEnum ipLimit = manager.getByName(ExamProperties.IP_LIMIT.name());
|
|
|
+ Map<String, String> properties = this.getProperties(bean.getId(), propertyKeyList);
|
|
|
+ bean.setProperties(properties);
|
|
|
|
|
|
- ExamPropertyEntity propertyEntity = examPropertyRepo.findByExamIdAndKeyId(next.getId(), ipLimit.getId());
|
|
|
- boolean ipLimited = null != propertyEntity && StringUtils.isNotBlank(propertyEntity.getValue()) && Boolean.parseBoolean(propertyEntity.getValue());
|
|
|
- bean.setIpLimitSettingsEnabled(ipLimited);
|
|
|
+ // String weixinAnswerEnabled = properties.get(ExamProperties.WEIXIN_ANSWER_ENABLED.name());
|
|
|
+ String ipLimitValue = properties.get(ExamProperties.IP_LIMIT.name());
|
|
|
+ bean.setIpLimitSettingsEnabled(StringUtil.isTrue(ipLimitValue));
|
|
|
}
|
|
|
|
|
|
- PageInfo<ExamDomain> ret = new PageInfo<>(page, list);
|
|
|
- return ret;
|
|
|
+ return new PageInfo<>(page, list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -449,9 +436,16 @@ public class ExamController extends ControllerSupport {
|
|
|
*/
|
|
|
private Map<String, String> getProperties(Long examId, List<String> propertyKeys) {
|
|
|
Map<String, String> map = Maps.newHashMap();
|
|
|
- DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
+ if (CollectionUtils.isEmpty(propertyKeys)) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
+ DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
|
|
|
for (String key : propertyKeys) {
|
|
|
+ if (map.containsKey(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
DynamicEnum de = manager.getByName(key);
|
|
|
ExamPropertyEntity one = examPropertyRepo.findByExamIdAndKeyId(examId, de.getId());
|
|
|
if (null != one) {
|
|
@@ -1487,36 +1481,30 @@ public class ExamController extends ControllerSupport {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "是否可以微信作答", notes = "")
|
|
|
+ @ApiOperation(value = "是否开放微信小程序作答", notes = "")
|
|
|
@GetMapping("weixinAnswerEnabled/{examId}")
|
|
|
- public Boolean weixinAnswerEnabled(@PathVariable Long examId) {
|
|
|
-
|
|
|
+ public Boolean weixinAnswerEnabled(@PathVariable Long examId, @RequestParam(required = false) String courseCode) {
|
|
|
ExamSettingsCacheBean examSettings = CacheHelper.getExamSettings(examId);
|
|
|
|
|
|
- OrgPropertyCacheBean orgConf = CacheHelper.getOrgProperty(examSettings.getRootOrgId(),
|
|
|
- "WEIXIN_ANSWER_ENABLED");
|
|
|
- ExamPropertyCacheBean examConf = CacheHelper.getExamProperty(examId,
|
|
|
- "WEIXIN_ANSWER_ENABLED");
|
|
|
+ OrgPropertyCacheBean orgConf = CacheHelper.getOrgProperty(examSettings.getRootOrgId(), "WEIXIN_ANSWER_ENABLED");
|
|
|
+ ExamPropertyCacheBean examConf = CacheHelper.getExamProperty(examId, "WEIXIN_ANSWER_ENABLED");
|
|
|
|
|
|
- String orgValue = orgConf.getValue();
|
|
|
- String examValue = examConf.getValue();
|
|
|
-
|
|
|
- if (!orgConf.getHasValue()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(orgValue)) {
|
|
|
+ if (!StringUtil.isTrue(orgConf.getValue())) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (StringUtils.isBlank(examValue)) {
|
|
|
+ if (!StringUtil.isTrue(examConf.getValue())) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (StringUtil.isTrue(orgValue.toString()) && StringUtil.isTrue(examValue)) {
|
|
|
- return true;
|
|
|
+ if (StringUtils.isNotBlank(courseCode)) {
|
|
|
+ ExamCourseRelationEntity entity = examCourseRelationRepo.findByExamIdAndCourseCode(examId, courseCode);
|
|
|
+ if (entity != null) {
|
|
|
+ return entity.getWeixinAnswerEnabled();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "是否支持人脸识别", notes = "")
|