From 4ba127459ff1b77df9014444fdac7636d3f091bc Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期六, 16 三月 2024 15:05:19 +0800
Subject: [PATCH] 题目导入
---
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java b/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
index 0f7dfc1..3a9c4f1 100644
--- a/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
+++ b/src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
@@ -4,19 +4,29 @@
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.ExamPaper;
import com.mindskip.xzs.domain.ExamPaperSubject;
+import com.mindskip.xzs.domain.vo.PaperExcelVO;
+import com.mindskip.xzs.domain.vo.UserCountExcelVO;
import com.mindskip.xzs.service.ExamPaperDepartmentService;
import com.mindskip.xzs.service.ExamPaperService;
import com.mindskip.xzs.service.ExamPaperSubjectService;
+import com.mindskip.xzs.service.ExamTemplatesUserCountService;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.PageInfoHelper;
+import com.mindskip.xzs.utility.excel.ExcelUtils;
+import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVO;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
import com.mindskip.xzs.viewmodel.admin.exam.ExamResponseVM;
import com.github.pagehelper.PageInfo;
+import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
+import java.util.Arrays;
+import java.util.List;
@RestController("AdminExamPaperController")
@RequestMapping(value = "/api/admin/exam/paper")
@@ -25,12 +35,14 @@
private final ExamPaperService examPaperService;
private final ExamPaperSubjectService examPaperSubjectService;
private final ExamPaperDepartmentService examPaperDepartmentService;
+ private final ExamTemplatesUserCountService examTemplatesUserCountService;
@Autowired
- public ExamPaperController(ExamPaperService examPaperService, ExamPaperSubjectService examPaperSubjectService, ExamPaperDepartmentService examPaperDepartmentService) {
+ public ExamPaperController(ExamPaperService examPaperService, ExamPaperSubjectService examPaperSubjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamTemplatesUserCountService examTemplatesUserCountService) {
this.examPaperService = examPaperService;
this.examPaperSubjectService = examPaperSubjectService;
this.examPaperDepartmentService = examPaperDepartmentService;
+ this.examTemplatesUserCountService = examTemplatesUserCountService;
}
@RequestMapping(value = "/page", method = RequestMethod.POST)
@@ -66,15 +78,21 @@
@RequestMapping(value = "/edit", method = RequestMethod.POST)
- public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) throws Exception {
+ public RestResponse<ExamPaperEditRequestVO> edit(@RequestBody @Valid ExamPaperEditRequestVM model) throws Exception {
+ Object[] obj = Arrays.stream(model.getUserIds()).sorted().distinct().toArray();
+ Integer[] userIds = new Integer[obj.length];
+ for(int i = 0;i<obj.length;i++) {
+ userIds[i] = (Integer)obj[i];
+ }
+ model.setUserIds(userIds);
ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser());
- ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId());
+ ExamPaperEditRequestVO newVM = examPaperService.examPaperToVM(examPaper.getId());
return RestResponse.ok(newVM);
}
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
- public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) {
- ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id);
+ public RestResponse<ExamPaperEditRequestVO> select(@PathVariable Integer id) {
+ ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id);
return RestResponse.ok(vm);
}
@@ -87,4 +105,11 @@
examPaperSubjectService.removeByExamPaperId(id);
return RestResponse.ok();
}
+
+ @RequestMapping(value = "/exportTemplatesId/{id}", method = RequestMethod.GET)
+ @SneakyThrows
+ public void exportTemplatesId(@PathVariable("id") Integer id, HttpServletResponse response, HttpServletRequest request) {
+ List<PaperExcelVO> list = examPaperService.getPaperExcelById(id);
+ ExcelUtils.export(response,"涓汉缁冧範",list,PaperExcelVO.class);
+ }
}
--
Gitblit v1.8.0