|
@@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.common.support.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.common.util.ErrorMsg;
|
|
|
import cn.com.qmth.examcloud.service.examwork.dao.ExamRepo;
|
|
@@ -139,8 +140,18 @@ public class ExamApi extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "新增考试批次", notes = "新增")
|
|
|
@PostMapping("/exam")
|
|
|
- public ResponseEntity addExam(HttpServletRequest request, @RequestBody Exam exam) {
|
|
|
- Map<String, String> errorMap = new HashMap<String, String>();
|
|
|
+ public Exam addExam(HttpServletRequest request, @RequestBody Exam exam) {
|
|
|
+
|
|
|
+ if (null != exam.getBeforeExamRemark() && exam.getBeforeExamRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "考前说明内容过大!");
|
|
|
+ }
|
|
|
+ if (null != exam.getAfterExamRemark() && exam.getAfterExamRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "考后说明内容过大!");
|
|
|
+ }
|
|
|
+ if (null != exam.getCheatingRemark() && exam.getCheatingRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "作弊说明内容过大!");
|
|
|
+ }
|
|
|
+
|
|
|
AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
|
|
|
if (accessUser != null) {
|
|
|
exam.setOrgId(accessUser.getOrgId());
|
|
@@ -148,25 +159,34 @@ public class ExamApi extends ControllerSupport {
|
|
|
exam.setCreateTime(new Date());
|
|
|
exam.setCanStuDel(true);
|
|
|
if (!examService.checkExamName(exam)) {
|
|
|
- errorMap.put("errorMsg", "考试名称已存在,请重新填写");
|
|
|
- return new ResponseEntity(errorMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ throw new StatusException("EXAMWORK-001001", "考试名称已存在,请重新填写");
|
|
|
}
|
|
|
- return new ResponseEntity(examService.insertExam(exam, accessUser), HttpStatus.OK);
|
|
|
+ Exam ret = examService.insertExam(exam, accessUser);
|
|
|
+ return ret;
|
|
|
} else {
|
|
|
- errorMap.put("errorMsg", "accessUser为空");
|
|
|
- return new ResponseEntity(errorMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ throw new StatusException("EXAMWORK-001002", "accessUser为空");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "更新考试批次", notes = "更新")
|
|
|
@PutMapping("/exam")
|
|
|
- public ResponseEntity updateExam(@RequestBody Exam exam) {
|
|
|
- Map<String, String> errorMap = new HashMap<String, String>();
|
|
|
+ public Exam updateExam(@RequestBody Exam exam) {
|
|
|
if (!examService.checkExamName(exam)) {
|
|
|
- errorMap.put("errorMsg", "考试名称已存在,请重新填写");
|
|
|
- return new ResponseEntity(errorMap, HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ throw new StatusException("EXAMWORK-001001", "考试名称已存在,请重新填写");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != exam.getBeforeExamRemark() && exam.getBeforeExamRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "考前说明内容过大!");
|
|
|
+ }
|
|
|
+ if (null != exam.getAfterExamRemark() && exam.getAfterExamRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "考后说明内容过大!");
|
|
|
+ }
|
|
|
+ if (null != exam.getCheatingRemark() && exam.getCheatingRemark().length() > 250000) {
|
|
|
+ throw new StatusException("EXAMWORK-001002", "作弊说明内容过大!");
|
|
|
}
|
|
|
- return new ResponseEntity(examService.saveExam(exam), HttpStatus.OK);
|
|
|
+
|
|
|
+ Exam ret = examService.saveExam(exam);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "按ID删除考试批次", notes = "删除")
|