|
|
|
|
package com.project.classicpaper.controller;
|
|
|
|
|
|
|
|
|
|
import com.project.base.domain.result.PageResult;
|
|
|
|
|
import com.project.base.domain.result.Result;
|
|
|
|
|
import com.project.classicpaper.application.ClassicPaperSetApplicationService;
|
|
|
|
|
import com.project.classicpaper.domain.dto.ClassicPaperSetDTO;
|
|
|
|
|
import com.project.classicpaper.domain.param.ClassicPaperSetParam;
|
|
|
|
|
import com.project.operation.annotation.OperationLog;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RequestMapping("/api/admin/classicPaperSet")
|
|
|
|
|
public class ClassicPaperSetController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ClassicPaperSetApplicationService classicPaperSetApplicationService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/generate")
|
|
|
|
|
@OperationLog(module = "经典套题")
|
|
|
|
|
public Result<ClassicPaperSetDTO> generate(ClassicPaperSetDTO request) throws Exception {
|
|
|
|
|
return classicPaperSetApplicationService.generate(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public Result<PageResult<ClassicPaperSetDTO>> list(ClassicPaperSetParam param) {
|
|
|
|
|
return classicPaperSetApplicationService.list(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/detail")
|
|
|
|
|
public Result<ClassicPaperSetDTO> detail(ClassicPaperSetParam param) {
|
|
|
|
|
return classicPaperSetApplicationService.getDetail(param.getId(), param.getPaperId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从 Word 文件导入历史套卷
|
|
|
|
|
* 解析 Word 文档 → 提取题目(含图片上传 MinIO) → 创建套题组(setCount=1)
|
|
|
|
|
*
|
|
|
|
|
* @param file Word 文件(.docx)
|
|
|
|
|
* @param classicCategoryId 套题二级分类ID
|
|
|
|
|
* @param paperName 套卷名称(可选,为空时取 Word 文档标题)
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/importWord")
|
|
|
|
|
@OperationLog(module = "经典套题")
|
|
|
|
|
public Result<ClassicPaperSetDTO> importFromWord(@RequestParam("file") MultipartFile file,
|
|
|
|
|
@RequestParam("classicCategoryId") Long classicCategoryId,
|
|
|
|
|
@RequestParam(value = "paperName", required = false) String paperName) throws Exception {
|
|
|
|
|
return classicPaperSetApplicationService.importFromWord(file, classicCategoryId, paperName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
|
|
@OperationLog(module = "经典套题")
|
|
|
|
|
public Result<String> delete(Long setId) throws Exception {
|
|
|
|
|
return classicPaperSetApplicationService.delete(setId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新分值比例,同时计算每道题的分值
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/save")
|
|
|
|
|
public Result<ClassicPaperSetDTO> save(ClassicPaperSetDTO request) throws Exception {
|
|
|
|
|
return classicPaperSetApplicationService.save(request);
|
|
|
|
|
}
|
|
|
|
|
}
|