|
@@ -15,13 +15,17 @@ import com.google.common.collect.Maps;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
import cn.com.qmth.examcloud.core.examwork.base.enums.ExamProperty;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgPropertyRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamOrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamPropertyRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamEntity;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgEntity;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgPropertyEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamPropertyEntity;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.ExamService;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.ExamInfo;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo;
|
|
|
|
|
|
/**
|
|
|
* 类注释
|
|
@@ -47,6 +51,9 @@ public class ExamServiceImpl implements ExamService {
|
|
|
@Autowired
|
|
|
ExamPropertyRepo examPropertyRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ExamOrgPropertyRepo examOrgPropertyRepo;
|
|
|
+
|
|
|
/**
|
|
|
* 删除考试批次
|
|
|
*
|
|
@@ -106,7 +113,46 @@ public class ExamServiceImpl implements ExamService {
|
|
|
exam.setRemark(examInfo.getRemark());
|
|
|
exam.setRootOrgId(examInfo.getRootOrgId());
|
|
|
|
|
|
+ if (null == exam.getExamType()) {
|
|
|
+ throw new StatusException("E-001005", "考试类型为空");
|
|
|
+ }
|
|
|
+
|
|
|
Map<String, String> properties = examInfo.getProperties();
|
|
|
+ Map<ExamProperty, String> map = checkAndGetExamProperties(properties);
|
|
|
+
|
|
|
+ ExamEntity findOne = examRepo.findByNameAndRootOrgId(exam.getName(), exam.getRootOrgId());
|
|
|
+ if (null != findOne && !findOne.getId().equals(exam.getId())) {
|
|
|
+ throw new StatusException("E-001001", "考试名称已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ ExamEntity saved = examRepo.save(exam);
|
|
|
+
|
|
|
+ for (Entry<ExamProperty, String> entry : map.entrySet()) {
|
|
|
+ ExamProperty prop = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(saved.getId(),
|
|
|
+ prop.getKeyId());
|
|
|
+ if (null == entity) {
|
|
|
+ entity = new ExamPropertyEntity();
|
|
|
+ entity.setExamId(saved.getId());
|
|
|
+ entity.setKeyId(prop.getKeyId());
|
|
|
+ }
|
|
|
+ entity.setValue(value);
|
|
|
+
|
|
|
+ examPropertyRepo.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ return saved;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 方法注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param properties
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<ExamProperty, String> checkAndGetExamProperties(Map<String, String> properties) {
|
|
|
Map<ExamProperty, String> map = Maps.newHashMap();
|
|
|
for (Entry<String, String> entry : properties.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
@@ -123,10 +169,6 @@ public class ExamServiceImpl implements ExamService {
|
|
|
map.put(ep, value.trim());
|
|
|
}
|
|
|
|
|
|
- if (null == exam.getExamType()) {
|
|
|
- throw new StatusException("E-001005", "考试类型为空");
|
|
|
- }
|
|
|
-
|
|
|
String beforeExamRemark = map.get(ExamProperty.BEFORE_EXAM_REMARK);
|
|
|
if (null != beforeExamRemark && beforeExamRemark.length() > 250000) {
|
|
|
throw new StatusException("E-001002", "考前说明内容过大");
|
|
@@ -142,26 +184,45 @@ public class ExamServiceImpl implements ExamService {
|
|
|
throw new StatusException("E-001002", "作弊说明内容过大");
|
|
|
}
|
|
|
|
|
|
- ExamEntity findOne = examRepo.findByNameAndRootOrgId(exam.getName(), exam.getRootOrgId());
|
|
|
- if (null != findOne && !findOne.getId().equals(exam.getId())) {
|
|
|
- throw new StatusException("E-001001", "考试名称已存在");
|
|
|
- }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
|
|
|
- ExamEntity saved = examRepo.save(exam);
|
|
|
+ /*
|
|
|
+ * 实现
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ *
|
|
|
+ * @see
|
|
|
+ * cn.com.qmth.examcloud.core.examwork.service.ExamService#saveExamOrg(cn.
|
|
|
+ * com.qmth.examcloud.core.examwork.service.bean.ExamOrgInfo)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ExamOrgEntity saveExamOrg(ExamOrgInfo examInfo) {
|
|
|
+ ExamOrgEntity examOrgEntity = new ExamOrgEntity();
|
|
|
+ examOrgEntity.setId(examInfo.getId());
|
|
|
+ examOrgEntity.setBeginTime(examInfo.getBeginTime());
|
|
|
+ examOrgEntity.setEndTime(examInfo.getEndTime());
|
|
|
+ examOrgEntity.setId(examInfo.getId());
|
|
|
+ examOrgEntity.setRootOrgId(examInfo.getRootOrgId());
|
|
|
+
|
|
|
+ Map<ExamProperty, String> map = checkAndGetExamProperties(examInfo.getProperties());
|
|
|
+
|
|
|
+ ExamOrgEntity saved = examOrgRepo.save(examOrgEntity);
|
|
|
|
|
|
for (Entry<ExamProperty, String> entry : map.entrySet()) {
|
|
|
ExamProperty prop = entry.getKey();
|
|
|
String value = entry.getValue();
|
|
|
- ExamPropertyEntity entity = examPropertyRepo.findByexamIdAndKeyId(saved.getId(),
|
|
|
- prop.getKeyId());
|
|
|
+ ExamOrgPropertyEntity entity = examOrgPropertyRepo.findByexamIdAndOrgIdAndKeyId(
|
|
|
+ saved.getExamId(), saved.getOrgId(), prop.getKeyId());
|
|
|
if (null == entity) {
|
|
|
- entity = new ExamPropertyEntity();
|
|
|
- entity.setExamId(saved.getId());
|
|
|
+ entity = new ExamOrgPropertyEntity();
|
|
|
+ entity.setExamId(saved.getExamId());
|
|
|
+ entity.setOrgId(saved.getOrgId());
|
|
|
entity.setKeyId(prop.getKeyId());
|
|
|
}
|
|
|
entity.setValue(value);
|
|
|
|
|
|
- examPropertyRepo.save(entity);
|
|
|
+ examOrgPropertyRepo.save(entity);
|
|
|
}
|
|
|
|
|
|
return saved;
|