xiangpei
2024-05-27 6dc4345f9c84d829566ae1632477f11c22fac2f5
src/main/java/com/mindskip/xzs/controller/admin/ExamTemplatesController.java
@@ -3,32 +3,30 @@
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.ExamPaper;
import com.mindskip.xzs.context.WebContext;
import com.mindskip.xzs.domain.ExamTemplates;
import com.mindskip.xzs.domain.ExamTemplatesSubject;
import com.mindskip.xzs.domain.User;
import com.mindskip.xzs.domain.vo.ExamTemplatesVO;
import com.mindskip.xzs.repository.DepartmentMapper;
import com.mindskip.xzs.repository.ExamTemplatesSubjectMapper;
import com.mindskip.xzs.service.ExamTemplatesService;
import com.mindskip.xzs.utility.PageInfoHelper;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
import lombok.extern.slf4j.Slf4j;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController("AdminExamTemplatesController")
@RequestMapping(value = "/api/admin/exam/templates")
@RequiredArgsConstructor
public class ExamTemplatesController extends BaseApiController {
    private final ExamTemplatesService examTemplatesService;
    private final ExamTemplatesSubjectMapper examTemplatesSubjectMapper;
    public ExamTemplatesController(ExamTemplatesService examTemplatesService, ExamTemplatesSubjectMapper examTemplatesSubjectMapper) {
        this.examTemplatesService = examTemplatesService;
        this.examTemplatesSubjectMapper = examTemplatesSubjectMapper;
    }
    private final WebContext webContext;
    private final DepartmentMapper departmentMapper;
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public RestResponse edit(@RequestBody @Valid ExamPaperEditRequestVM model) {
@@ -38,7 +36,9 @@
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public RestResponse<PageInfo<ExamTemplatesVO>> list(ExamTemplatesVO examTemplatesVO) throws Exception {
        PageInfo<ExamTemplates> pageInfo = examTemplatesService.gets(examTemplatesVO);
        // 如果是部门管理员,需要做数据权限
        examTemplatesVO.setDeptId(ObjectUtils.isNotEmpty(examTemplatesVO.getDeptId()) ? examTemplatesVO.getDeptId() : getAdminDeptIds());
        PageInfo<ExamTemplates> pageInfo = examTemplatesService.getByadmins(examTemplatesVO);
        PageInfo<ExamTemplatesVO> info = PageInfoHelper.copyMap(pageInfo, e -> {
            ExamTemplatesVO vo = new ExamTemplatesVO();
            vo.setName(e.getName());