package jnpf.tmsController;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jnpf.base.ActionResult;
|
import jnpf.base.vo.PageListVO;
|
import jnpf.base.vo.PaginationVO;
|
import jnpf.tmsEntity.selftest.TmsSelfTestPaperVO;
|
import jnpf.tmsEntity.selftest.TmsSelfTestQuery;
|
import jnpf.tmsEntity.selftest.TmsSelfTestRecordVO;
|
import jnpf.tmsEntity.selftest.TmsSelfTestStartForm;
|
import jnpf.tmsEntity.selftest.TmsSelfTestSubmitForm;
|
import jnpf.tmsEntity.selftest.TmsSelfTestSubmitResultVO;
|
import jnpf.tmsService.TmsSelfTestService;
|
import jnpf.util.JsonUtil;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
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.RestController;
|
|
import java.util.List;
|
|
/**
|
* 自我检测。网关 /api/tms/self-test/** (StripPrefix=2)→ /self-test/**
|
*/
|
@Tag(name = "TMS自我检测", description = "SelfTest")
|
@RestController
|
@RequestMapping("/self-test")
|
@RequiredArgsConstructor
|
public class TmsSelfTestController {
|
|
private final TmsSelfTestService selfTestService;
|
|
@Operation(summary = "开始自我检测(抽题)")
|
@PostMapping("/start")
|
public ActionResult<TmsSelfTestPaperVO> start(@RequestBody TmsSelfTestStartForm form) {
|
return ActionResult.success(selfTestService.start(form));
|
}
|
|
@Operation(summary = "暂存作答(不交卷)")
|
@PostMapping("/{id}/save")
|
public ActionResult<String> save(@PathVariable("id") String id,
|
@RequestBody TmsSelfTestSubmitForm form) {
|
selfTestService.saveAnswers(id, form);
|
return ActionResult.success("暂存成功");
|
}
|
|
@Operation(summary = "交卷")
|
@PostMapping("/{id}/submit")
|
public ActionResult<TmsSelfTestSubmitResultVO> submit(@PathVariable("id") String id,
|
@RequestBody TmsSelfTestSubmitForm form) {
|
return ActionResult.success(selfTestService.submit(id, form));
|
}
|
|
@Operation(summary = "我的检测记录")
|
@GetMapping("/list")
|
public ActionResult<PageListVO<TmsSelfTestRecordVO>> list(TmsSelfTestQuery query) {
|
List<TmsSelfTestRecordVO> list = selfTestService.getList(query);
|
PageListVO<TmsSelfTestRecordVO> vo = new PageListVO<>();
|
vo.setList(list);
|
vo.setPagination(JsonUtil.getJsonToBean(query, PaginationVO.class));
|
return ActionResult.success(vo);
|
}
|
|
@Operation(summary = "检测详情(重做回顾)")
|
@GetMapping("/{id}")
|
public ActionResult<TmsSelfTestPaperVO> info(@PathVariable("id") String id) {
|
return ActionResult.success(selfTestService.getInfo(id));
|
}
|
}
|