|
@@ -114,7 +114,7 @@ public class TEExamController {
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
@Transactional
|
|
|
public Result toggle(@ApiJsonObject(name = "toggle", value = {
|
|
|
- @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次id"),
|
|
|
+ @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次ID"),
|
|
|
@ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")
|
|
|
}) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
|
|
@@ -136,4 +136,68 @@ public class TEExamController {
|
|
|
teExamService.updateById(teExam);
|
|
|
return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试批次详情接口")
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
|
|
|
+ public Result detail(@ApiParam(value = "考试批次id", required = true) @RequestParam Long id) {
|
|
|
+ TEExam teExam = teExamService.getById(id);
|
|
|
+ if (Objects.isNull(teExam)) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
+ }
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, teExam);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试批次复制接口")
|
|
|
+ @RequestMapping(value = "/copy", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @Transactional
|
|
|
+ public Result copy(@ApiJsonObject(name = "copy", value = {
|
|
|
+ @ApiJsonProperty(key = "sourceId", type = "long", example = "1", description = "来源批次ID"),
|
|
|
+ @ApiJsonProperty(key = "code", description = "代码"),
|
|
|
+ @ApiJsonProperty(key = "name", description = "名称")
|
|
|
+ }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
|
|
|
+ if (Objects.isNull(mapParameter.get("sourceId")) || Objects.equals(mapParameter.get("sourceId"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
|
+ }
|
|
|
+ Long examId = Long.parseLong(String.valueOf(mapParameter.get("sourceId")));
|
|
|
+ if (Objects.isNull(mapParameter.get("code")) || Objects.equals(mapParameter.get("code"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_CODE_IS_NULL);
|
|
|
+ }
|
|
|
+ String code = String.valueOf(mapParameter.get("code"));
|
|
|
+ if (Objects.isNull(mapParameter.get("name")) || Objects.equals(mapParameter.get("name"), "")) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_NAME_IS_NULL);
|
|
|
+ }
|
|
|
+ String name = String.valueOf(mapParameter.get("name"));
|
|
|
+ TEExam teExam = teExamService.getById(examId);
|
|
|
+ if (Objects.isNull(teExam)) {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.EXAM_NO);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ teExam.setId(null);
|
|
|
+ teExam.setUpdateId(null);
|
|
|
+ teExam.setUpdateTime(null);
|
|
|
+ HttpServletRequest request = ServletUtil.getRequest();
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
|
|
|
+ teExam.setCreateId(tbUser.getId());
|
|
|
+ teExam.setCode(code);
|
|
|
+ teExam.setName(name);
|
|
|
+ teExamService.save(teExam);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
+ throw new BusinessException("机构id[" + teExam.getOrgId() + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
|
|
|
+ } else if (e instanceof BusinessException) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //todo 还需增加场次设置
|
|
|
+ return ResultUtil.ok(JSONObject.parseObject(SystemConstant.SUCCESS));
|
|
|
+ }
|
|
|
}
|