123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package cn.com.qmth.mps.controller;
- import java.util.List;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.commons.collections4.CollectionUtils;
- 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 org.springframework.web.multipart.MultipartFile;
- import com.qmth.boot.api.annotation.Aac;
- import com.qmth.boot.api.annotation.BOOL;
- import com.qmth.boot.api.constant.ApiConstant;
- import com.qmth.boot.core.collection.PageResult;
- import cn.com.qmth.mps.bean.ImportMsg;
- import cn.com.qmth.mps.service.PaperDetailService;
- import cn.com.qmth.mps.service.PaperGroupService;
- import cn.com.qmth.mps.service.PaperService;
- import cn.com.qmth.mps.util.ResouceUtil;
- import cn.com.qmth.mps.vo.paper.GroupInfoVo;
- import cn.com.qmth.mps.vo.paper.GroupVo;
- import cn.com.qmth.mps.vo.paper.PaperGroupDomain;
- import cn.com.qmth.mps.vo.paper.PaperInfoVo;
- import cn.com.qmth.mps.vo.paper.PaperQuery;
- import cn.com.qmth.mps.vo.paper.PaperVo;
- import cn.com.qmth.mps.vo.paper.StructDomain;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- @RestController
- @Api(tags = "试卷结构接口")
- @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/paper")
- @Aac(strict = BOOL.FALSE, auth = BOOL.TRUE)
- public class PaperController extends BaseController {
- @Autowired
- private PaperService paperService;
-
- @Autowired
- private PaperGroupService paperGroupService;
-
- @Autowired
- private PaperDetailService paperDetailService;
- @PostMapping("import-course")
- @ApiOperation(value = "导入科目")
- public ImportMsg importPaper(@RequestParam Long examId, @RequestParam MultipartFile file) {
- List<String> failRecords = paperService.importPaper(examId, getAccessUser(), file);
- ImportMsg msg = new ImportMsg();
- msg.setHasError(CollectionUtils.isNotEmpty(failRecords));
- msg.setErrMsg(failRecords);
- return msg;
- }
- @PostMapping("import-struct-subject")
- @ApiOperation(value = "导入主观题试卷结构")
- public ImportMsg importSubjectStruct(@RequestParam Long examId, @RequestParam MultipartFile file) {
- List<String> failRecords = paperService.importPaper(examId, getAccessUser(), file);
- ImportMsg msg = new ImportMsg();
- msg.setHasError(CollectionUtils.isNotEmpty(failRecords));
- msg.setErrMsg(failRecords);
- return msg;
- }
- @ApiOperation(value = "下载科目导入模板")
- @PostMapping("template-course")
- public void getImportTemplate() {
- exportFile("科目导入模板.xlsx", ResouceUtil.getStream("importtemplates/courseImport.xlsx"));
- }
- @ApiOperation(value = "下载试卷结构导入模板")
- @PostMapping("template-struct")
- public void getStructImportTemplate() {
- exportFile("试卷结构导入模板.xlsx", ResouceUtil.getStream("importtemplates/structImport.xlsx"));
- }
- @ApiOperation(value = "导出主观题")
- @PostMapping("export-subjective")
- public void exportSubjective(PaperQuery query, HttpServletResponse response) {
- }
- @ApiOperation(value = "获取分页")
- @RequestMapping(value = "page", method = RequestMethod.POST)
- public PageResult<PaperVo> page(PaperQuery query) {
- return paperService.page(query, getAccessUser());
- }
- @ApiOperation(value = "获取列表")
- @RequestMapping(value = "list", method = RequestMethod.POST)
- public List<PaperVo> list(@RequestParam Long examId) {
- return paperService.list(examId, getAccessUser());
- }
- @ApiOperation(value = "获取信息")
- @RequestMapping(value = "info", method = RequestMethod.POST)
- public PaperInfoVo info(@RequestParam Long paperId) {
- return paperService.info(paperId, getAccessUser());
- }
- @ApiOperation(value = "试卷结构提交")
- @RequestMapping(value = "struct/submit ", method = RequestMethod.POST)
- public void structSubmit(@RequestBody StructDomain domain) {
- paperDetailService.structSubmit(domain,getAccessUser());
- }
- @ApiOperation(value = "试卷结构暂存")
- @RequestMapping(value = "struct/save ", method = RequestMethod.POST)
- public void structSave(@RequestBody StructDomain domain) {
- paperDetailService.structSave(domain,getAccessUser());
- }
- @ApiOperation(value = "获取分组列表")
- @RequestMapping(value = "group/list", method = RequestMethod.POST)
- public List<GroupVo> groupList(@RequestParam Long paperId) {
- return paperGroupService.groupList(paperId,getAccessUser());
- }
- @ApiOperation(value = "获取分组信息")
- @RequestMapping(value = "group/info", method = RequestMethod.POST)
- public GroupInfoVo groupInfo(@RequestParam Long paperId, @RequestParam Integer groupNumber) {
- return paperGroupService.groupInfo(paperId,groupNumber,getAccessUser());
- }
- @ApiOperation(value = "保存分组信息")
- @RequestMapping(value = "group/save", method = RequestMethod.POST)
- public void groupSave(@RequestBody PaperGroupDomain domain) {
- paperGroupService.groupSave(domain,getAccessUser());
- }
-
- @ApiOperation(value = "删除分组信息")
- @RequestMapping(value = "group/delete", method = RequestMethod.POST)
- public void groupDelete(@RequestParam Long paperId, @RequestParam Integer groupNumber) {
- paperGroupService.groupDelete(paperId,groupNumber,getAccessUser());
- }
-
- @ApiOperation(value = "清空分组信息")
- @RequestMapping(value = "group/clear", method = RequestMethod.POST)
- public void groupClear(@RequestParam Long paperId) {
- paperGroupService.groupClear(paperId,getAccessUser());
- }
- }
|