|
@@ -0,0 +1,147 @@
|
|
|
+package cn.com.qmth.scancentral.controller.admin;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.qmth.boot.api.annotation.Aac;
|
|
|
+import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.boot.core.collection.PageResult;
|
|
|
+
|
|
|
+import cn.com.qmth.scancentral.bean.User;
|
|
|
+import cn.com.qmth.scancentral.controller.BaseController;
|
|
|
+import cn.com.qmth.scancentral.entity.ExamEntity;
|
|
|
+import cn.com.qmth.scancentral.exception.ParameterExceptions;
|
|
|
+import cn.com.qmth.scancentral.service.ExamService;
|
|
|
+import cn.com.qmth.scancentral.vo.ExamConfigVo;
|
|
|
+import cn.com.qmth.scancentral.vo.ExamVo;
|
|
|
+import cn.com.qmth.scancentral.vo.ResultVo;
|
|
|
+import cn.com.qmth.scancentral.vo.UpdateTimeVo;
|
|
|
+import cn.com.qmth.scancentral.vo.examinfo.ExamEdit;
|
|
|
+import cn.com.qmth.scancentral.vo.examinfo.ExamOverview;
|
|
|
+import cn.com.qmth.scancentral.vo.examinfo.ExamQuery;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@Api(tags = "异步任务接口")
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/async-task")
|
|
|
+@Aac(strict = false, auth = true)
|
|
|
+public class AsyncTaskController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "扫描点代码获取")
|
|
|
+ @PostMapping(value = "scan-site")
|
|
|
+ public String getScanSite(@RequestParam Long examId) {
|
|
|
+ return examService.getScanSite(examId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "扫描点代码设置")
|
|
|
+ @PostMapping(value = "scan-site/save")
|
|
|
+ public UpdateTimeVo scanSiteSave(@RequestParam Long examId, @RequestParam String scanSite) {
|
|
|
+ examService.scanSiteSave(examId, scanSite);
|
|
|
+ return UpdateTimeVo.create();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试概览数据")
|
|
|
+ @RequestMapping(value = "/overview", method = RequestMethod.POST)
|
|
|
+ public ExamOverview overview(@RequestParam Long examId) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return examService.getExamOverview(examId, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取考试列表")
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
+ public PageResult<ExamVo> list(ExamQuery query) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ return examService.pageQuery(query, user);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "新建、修改考试")
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ public ResultVo save(ExamEdit exam) {
|
|
|
+ exam.setOperateUserId(getAccessUser().getId());
|
|
|
+ examService.save(exam);
|
|
|
+ return new ResultVo(System.currentTimeMillis());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取基础数据配置")
|
|
|
+ @RequestMapping(value = "/config/info", method = RequestMethod.POST)
|
|
|
+ public ExamConfigVo getConfigInfo(@RequestParam Long examId) {
|
|
|
+ return examService.getConfigInfo(examId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存基础数据配置")
|
|
|
+ @RequestMapping(value = "/config/save", method = RequestMethod.POST)
|
|
|
+ public ResultVo saveConfig(@Valid @RequestBody ExamConfigVo config) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ examService.saveConfig(config, user);
|
|
|
+ return new ResultVo(System.currentTimeMillis());
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "启用、禁用考试")
|
|
|
+ @RequestMapping(value = "/toggle", method = RequestMethod.POST)
|
|
|
+ public ResultVo updateEnable(@RequestParam Long examId, @RequestParam Boolean enable) {
|
|
|
+ User user = getAccessUser();
|
|
|
+ ExamEntity exam = examService.getById(examId);
|
|
|
+ if (exam == null) {
|
|
|
+ throw ParameterExceptions.EXAM_NOT_FOUND;
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<ExamEntity> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(ExamEntity::getEnable, enable);
|
|
|
+ updateWrapper.set(ExamEntity::getUpdateTime, System.currentTimeMillis());
|
|
|
+ updateWrapper.set(ExamEntity::getUpdaterId, user.getId());
|
|
|
+ updateWrapper.eq(ExamEntity::getId, exam.getId());
|
|
|
+ examService.update(updateWrapper);
|
|
|
+
|
|
|
+ return new ResultVo(System.currentTimeMillis());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|