|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.api.provider;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamService;
|
|
@@ -32,6 +34,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
@Autowired
|
|
|
private ExamService examService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ExamRepo examRepo;
|
|
|
+
|
|
|
@ApiOperation(value = "新增考试批次", notes = "新增")
|
|
|
@PostMapping
|
|
|
@Override
|
|
@@ -56,9 +61,28 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
|
|
|
@PostMapping("/findExam")
|
|
|
@Override
|
|
|
public GetExamResp getExam(@RequestBody GetExamReq req) {
|
|
|
- Exam exam = examService.findExamByNameAndRootOrgId(req.getName(), req.getRootOrgId());
|
|
|
+ Long id = req.getId();
|
|
|
+ Long rootOrgId = req.getRootOrgId();
|
|
|
+ String name = req.getName();
|
|
|
+ if (null == id && StringUtils.isBlank(name)) {
|
|
|
+ throw new StatusException("E-002002", "id,name不能都为空");
|
|
|
+ }
|
|
|
+ if (null != id && StringUtils.isNotBlank(name)) {
|
|
|
+ throw new StatusException("E-002003", "id,name不能都不为空");
|
|
|
+ }
|
|
|
+ Exam exam = null;
|
|
|
+
|
|
|
+ if (null != id) {
|
|
|
+ exam = examRepo.findOne(id);
|
|
|
+ } else if (StringUtils.isNotBlank(name)) {
|
|
|
+ if (null == rootOrgId) {
|
|
|
+ throw new StatusException("E-002004", "rootOrgId is null");
|
|
|
+ }
|
|
|
+ exam = examService.findExamByNameAndRootOrgId(name, rootOrgId);
|
|
|
+ }
|
|
|
+
|
|
|
if (null == exam) {
|
|
|
- throw new StatusException("E-002002", "考试不存在");
|
|
|
+ throw new StatusException("E-002005", "考试不存在");
|
|
|
}
|
|
|
GetExamResp examResp = new GetExamResp();
|
|
|
examResp.setId(exam.getId());
|