package jnpf.tmsController; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jnpf.annotation.HandleLog; import jnpf.base.ActionResult; import jnpf.base.vo.PageListVO; import jnpf.base.vo.PaginationVO; import jnpf.tmsEntity.paper.TmsPaperExportForm; import jnpf.tmsEntity.paper.TmsPaperForm; import jnpf.tmsEntity.paper.TmsPaperQuery; import jnpf.tmsService.TmsPaperService; 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.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; /** * 试卷管理(含组卷)。网关 /api/tms/paper/** (StripPrefix=2)→ /paper/** */ @Tag(name = "TMS试卷", description = "Paper") @RestController @RequestMapping("/paper") @RequiredArgsConstructor public class TmsPaperController { private final TmsPaperService paperService; @Operation(summary = "试卷分页列表") @GetMapping("/list") public ActionResult> list(TmsPaperQuery query) { List list = paperService.getList(query); PageListVO vo = new PageListVO<>(); vo.setList(list); vo.setPagination(JsonUtil.getJsonToBean(query, PaginationVO.class)); return ActionResult.success(vo); } @HandleLog(moduleName = "试卷管理", requestMethod = "导出") @Operation(summary = "导出试卷试题清单") @PostMapping("/export") public void export(@RequestBody TmsPaperExportForm form, HttpServletResponse response) { paperService.exportQuestions(form, response); } @Operation(summary = "试卷详情(含章节与试题)") @GetMapping("/{id}") public ActionResult info(@PathVariable("id") String id) { return ActionResult.success(paperService.getInfo(id)); } @HandleLog(moduleName = "试卷管理", requestMethod = "新增") @Operation(summary = "新增试卷(组卷)") @PostMapping public ActionResult create(@RequestBody TmsPaperForm form) { return ActionResult.success(paperService.create(form)); } @HandleLog(moduleName = "试卷管理", requestMethod = "修改") @Operation(summary = "更新试卷(组卷)") @PutMapping("/{id}") public ActionResult update(@PathVariable("id") String id, @RequestBody TmsPaperForm form) { paperService.update(id, form); return ActionResult.success("更新成功"); } @HandleLog(moduleName = "试卷管理", requestMethod = "废弃") @Operation(summary = "废弃试卷") @PutMapping("/{id}/invalidate") public ActionResult invalidate(@PathVariable("id") String id) { paperService.invalidate(id); return ActionResult.success("废弃成功"); } @HandleLog(moduleName = "试卷管理", requestMethod = "状态变更") @Operation(summary = "启用/停用试卷(开放/不开放)") @PutMapping("/{id}/status") public ActionResult status(@PathVariable("id") String id, @RequestBody Map body) { paperService.setBizStatus(id, body == null ? null : body.get("bizStatus")); return ActionResult.success("操作成功"); } }