|
@@ -1,8 +1,26 @@
|
|
|
package com.qmth.themis.backend.api;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.qmth.themis.backend.util.ServletUtil;
|
|
|
+import com.qmth.themis.business.constant.SystemConstant;
|
|
|
+import com.qmth.themis.business.entity.TBUser;
|
|
|
+import com.qmth.themis.business.entity.TEExamActivity;
|
|
|
+import com.qmth.themis.business.enums.FieldUniqueEnum;
|
|
|
+import com.qmth.themis.business.service.TEExamActivityService;
|
|
|
+import com.qmth.themis.business.util.JacksonUtil;
|
|
|
+import com.qmth.themis.common.contanst.Constants;
|
|
|
+import com.qmth.themis.common.exception.BusinessException;
|
|
|
+import com.qmth.themis.common.util.Result;
|
|
|
+import com.qmth.themis.common.util.ResultUtil;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 考试场次 前端控制器
|
|
@@ -13,7 +31,51 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
*/
|
|
|
@Api(tags = "考试场次Controller")
|
|
|
@RestController
|
|
|
-@RequestMapping("/${prefix.url.admin}/examActivity")
|
|
|
+@RequestMapping("/${prefix.url.admin}/activity")
|
|
|
public class TEExamActivityController {
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamActivityService teExamActivityService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试场次修改/新增接口")
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ @Transactional
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ public Result save(@ApiParam(value = "考试场次信息", required = true) @RequestBody List<TEExamActivity> teExamActivityList) {
|
|
|
+ try {
|
|
|
+ HttpServletRequest request = ServletUtil.getRequest();
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
|
|
|
+ teExamActivityList.forEach(s -> {
|
|
|
+ if (Objects.nonNull(s.getId())) {
|
|
|
+ s.setUpdateId(tbUser.getId());
|
|
|
+ } else {
|
|
|
+ s.setId(Constants.idGen.next());
|
|
|
+ s.setCreateId(tbUser.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ teExamActivityService.saveOrUpdateBatch(teExamActivityList);
|
|
|
+ } 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[" + teExamActivityList.get(0).getExamId() + "]下的" + FieldUniqueEnum.convertToCode(columnStr) + "数据不允许重复插入");
|
|
|
+ } else if (e instanceof BusinessException) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试场次查询接口")
|
|
|
+ @RequestMapping(value = "/query", method = RequestMethod.GET)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试场次信息", response = TEExamActivity.class)})
|
|
|
+ public Result query(@ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long examId, @ApiParam(value = "考试场次编码", required = false) @RequestParam(required = false) String code, @ApiParam(value = "开始日期", required = false) @RequestParam(required = false) String startDate, @ApiParam(value = "结束日期", required = false) @RequestParam(required = false) String finishDate, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
|
|
|
+ IPage<TEExamActivity> teExamActivityIPage = teExamActivityService.examActivityQuery(new Page<>(pageNumber, pageSize), examId, code, startDate, finishDate);
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put(SystemConstant.RECORDS, teExamActivityIPage);
|
|
|
+ return ResultUtil.ok(map);
|
|
|
+ }
|
|
|
}
|