qirong
2023-06-16 1f16aa96a1f88be11f33efcb2862218be4342e44
src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
@@ -3,7 +3,10 @@
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.ExamPaper;
import com.mindskip.xzs.domain.ExamPaperSubject;
import com.mindskip.xzs.service.ExamPaperDepartmentService;
import com.mindskip.xzs.service.ExamPaperService;
import com.mindskip.xzs.service.ExamPaperSubjectService;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.PageInfoHelper;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
@@ -20,10 +23,14 @@
public class ExamPaperController extends BaseApiController {
    private final ExamPaperService examPaperService;
    private final ExamPaperSubjectService examPaperSubjectService;
    private final ExamPaperDepartmentService examPaperDepartmentService;
    @Autowired
    public ExamPaperController(ExamPaperService examPaperService) {
    public ExamPaperController(ExamPaperService examPaperService, ExamPaperSubjectService examPaperSubjectService, ExamPaperDepartmentService examPaperDepartmentService) {
        this.examPaperService = examPaperService;
        this.examPaperSubjectService = examPaperSubjectService;
        this.examPaperDepartmentService = examPaperDepartmentService;
    }
    @RequestMapping(value = "/page", method = RequestMethod.POST)
@@ -32,6 +39,8 @@
        PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
            ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class);
            vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
            vm.setSubjectId(examPaperSubjectService.getByExamPaperId(vm.getId())
                    .stream().map(ExamPaperSubject::getSubjectId).toArray(Integer[]::new));
            return vm;
        });
        return RestResponse.ok(page);
@@ -70,6 +79,8 @@
        ExamPaper examPaper = examPaperService.selectById(id);
        examPaper.setDeleted(true);
        examPaperService.updateByIdFilter(examPaper);
        examPaperDepartmentService.removeByExamPaperId(id);
        examPaperSubjectService.removeByExamPaperId(id);
        return RestResponse.ok();
    }
}