|
@@ -14,6 +14,9 @@ import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
|
|
|
import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnumManager;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
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.ExamOrgSettingsRepo;
|
|
@@ -26,6 +29,8 @@ 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.ExamOrgSettingsInfo;
|
|
|
+import cn.com.qmth.examcloud.task.api.DataSyncCloudService;
|
|
|
+import cn.com.qmth.examcloud.task.api.request.SyncExamReq;
|
|
|
|
|
|
/**
|
|
|
* 类注释
|
|
@@ -54,6 +59,9 @@ public class ExamServiceImpl implements ExamService {
|
|
|
@Autowired
|
|
|
ExamOrgPropertyRepo examOrgPropertyRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DataSyncCloudService dataSyncCloudService;
|
|
|
+
|
|
|
/**
|
|
|
* 方法注释
|
|
|
*
|
|
@@ -81,8 +89,34 @@ public class ExamServiceImpl implements ExamService {
|
|
|
@Override
|
|
|
public ExamEntity saveExam(ExamInfo examInfo) {
|
|
|
|
|
|
- ExamEntity exam = new ExamEntity();
|
|
|
- exam.setId(examInfo.getId());
|
|
|
+ if (null == examInfo.getExamType()) {
|
|
|
+ throw new StatusException("E-001005", "考试类型为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(examInfo.getName())) {
|
|
|
+ throw new StatusException("E-001005", "考试名称为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null == examInfo.getRootOrgId()) {
|
|
|
+ throw new StatusException("E-001005", "rootOrgId is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
+ getOrgReq.setOrgId(examInfo.getRootOrgId());
|
|
|
+ GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
+ OrgBean rootOrg = getOrgResp.getOrg();
|
|
|
+
|
|
|
+ Map<String, String> properties = examInfo.getProperties();
|
|
|
+ Map<DynamicEnum, String> map = checkAndGetExamProperties(properties);
|
|
|
+
|
|
|
+ ExamEntity exam = examRepo.findByNameAndRootOrgId(examInfo.getName(),
|
|
|
+ examInfo.getRootOrgId());
|
|
|
+ if (null != exam) {
|
|
|
+ if (!exam.getId().equals(examInfo.getId())) {
|
|
|
+ throw new StatusException("E-001001", "考试名称已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
exam.setBeginTime(examInfo.getBeginTime());
|
|
|
exam.setDuration(examInfo.getDuration());
|
|
|
exam.setEnable(examInfo.getEnable());
|
|
@@ -94,18 +128,6 @@ 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<DynamicEnum, 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<DynamicEnum, String> entry : map.entrySet()) {
|
|
@@ -123,6 +145,20 @@ public class ExamServiceImpl implements ExamService {
|
|
|
examPropertyRepo.save(entity);
|
|
|
}
|
|
|
|
|
|
+ SyncExamReq req = new SyncExamReq();
|
|
|
+ req.setBeginTime(exam.getBeginTime());
|
|
|
+ req.setDuration(exam.getDuration());
|
|
|
+ req.setEnable(exam.getEnable());
|
|
|
+ req.setEndTime(exam.getEndTime());
|
|
|
+ req.setExamTimes(exam.getExamTimes());
|
|
|
+ req.setExamType(exam.getExamType().name());
|
|
|
+ req.setName(exam.getName());
|
|
|
+ req.setRemark(exam.getRemark());
|
|
|
+ req.setRootOrgId(exam.getRootOrgId());
|
|
|
+ req.setRootOrgName(rootOrg.getName());
|
|
|
+ req.setSyncType("update");
|
|
|
+ dataSyncCloudService.syncExam(req);
|
|
|
+
|
|
|
return saved;
|
|
|
}
|
|
|
|