xiangpei
2025-05-14 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
@@ -15,12 +15,8 @@
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.ExamPaperEditRequestVM;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVO;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
import com.mindskip.xzs.viewmodel.admin.exam.ExamResponseVM;
import com.mindskip.xzs.viewmodel.admin.exam.*;
import lombok.SneakyThrows;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -50,7 +46,7 @@
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public RestResponse<PageInfo<ExamResponseVM>> pageList(@RequestBody ExamPaperPageRequestVM model) {
        model.setDeptIds(ObjectUtils.isNotEmpty(model.getDeptIds()) ? model.getDeptIds() : getAdminDeptIds());
//        model.setDeptIds(ObjectUtils.isNotEmpty(model.getDeptIds()) ? model.getDeptIds() : getAdminDeptIds());
        if (Objects.nonNull(model.getLevel())) {
            model.setDeptIds(Collections.singletonList(model.getLevel()));
        }
@@ -61,6 +57,7 @@
            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            vm.setSubjectId(examPaperSubjectService.getByExamPaperId(vm.getId())
                    .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new));
            vm.setCreateDepartment(examPaperDepartmentService.selectByUserId(vm.getCreateUser()));
            return vm;
        });
        return RestResponse.ok(page);
@@ -123,6 +120,14 @@
    @RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
    public RestResponse<ExamPaperEditRequestVO> select(@PathVariable Integer id) {
        ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id);
        for (ExamPaperTitleItemVO titleItem : vm.getTitleItems()) {
            titleItem.getQuestionItems().stream().forEach(question -> {
                // 清空答案、解析
                question.setCorrect("");
                question.setAnalyze("");
                question.setCorrectArray(null);
            });
        }
        return RestResponse.ok(vm);
    }
@@ -154,4 +159,9 @@
        List<Integer> adminDeptIds = getAdminDeptIds();
        return RestResponse.ok(examPaperService.selectStudent(userVO, adminDeptIds));
    }
    @RequestMapping(value = "/queryCondition", method = RequestMethod.GET)
    public RestResponse<List<ExamPaper>> queryCondition() {
        return RestResponse.ok(examPaperService.queryCondition());
    }
}