xiangpei
2025-05-14 47cd9ecc0eff38ffe6b3b794b2bf197e958f4403
src/main/java/com/mindskip/xzs/controller/admin/ExamTemplatesController.java
@@ -5,12 +5,15 @@
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.context.WebContext;
import com.mindskip.xzs.domain.ExamTemplates;
import com.mindskip.xzs.domain.ExamTemplatesConfig;
import com.mindskip.xzs.domain.ExamTemplatesSubject;
import com.mindskip.xzs.domain.vo.ExamTemplatesVO;
import com.mindskip.xzs.repository.ExamTemplatesSubjectMapper;
import com.mindskip.xzs.service.ExamPaperDepartmentService;
import com.mindskip.xzs.service.ExamTemplatesConfigService;
import com.mindskip.xzs.service.ExamTemplatesService;
import com.mindskip.xzs.utility.PageInfoHelper;
import com.mindskip.xzs.utility.minio.DateUtils;
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
@@ -18,6 +21,7 @@
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@RestController("AdminExamTemplatesController")
@@ -26,6 +30,7 @@
public class ExamTemplatesController extends BaseApiController {
    private final ExamTemplatesService examTemplatesService;
    private final ExamTemplatesConfigService examTemplatesConfigService;
    private final ExamTemplatesSubjectMapper examTemplatesSubjectMapper;
    private final WebContext webContext;
    private final ExamPaperDepartmentService examPaperDepartmentService;
@@ -37,8 +42,8 @@
        return RestResponse.ok();
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public RestResponse<PageInfo<ExamTemplatesVO>> list(ExamTemplatesVO examTemplatesVO) throws Exception {
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public RestResponse<PageInfo<ExamTemplatesVO>> list(@RequestBody ExamTemplatesVO examTemplatesVO) throws Exception {
        // 如果是部门管理员,需要做数据权限
        examTemplatesVO.setDeptId(ObjectUtils.isNotEmpty(examTemplatesVO.getDeptId()) ? examTemplatesVO.getDeptId() : getAdminDeptIds());
        PageInfo<ExamTemplates> pageInfo = examTemplatesService.getByadmins(examTemplatesVO);
@@ -70,10 +75,18 @@
        return RestResponse.ok();
    }
//    @RequestMapping(value = "/random", method = RequestMethod.POST)
//    public RestResponse<Integer> randomExam() throws Exception {
//        User user = getCurrentUser();
//        Integer id = examTemplatesService.randomExam(user);
//        return RestResponse.ok(id);
//    }
    @PostMapping("/setConfig")
    public RestResponse<Boolean> setConfig(@RequestBody ExamTemplatesConfig examTemplatesConfig) {
        if (Objects.isNull(examTemplatesConfig.getId())) {
            examTemplatesConfig.setCreateUser(getCurrentUser().getId());
            examTemplatesConfig.setCreateTime(DateUtils.getNowDate());
        }
        return RestResponse.ok(examTemplatesConfigService.saveOrUpdate(examTemplatesConfig));
    }
    @GetMapping("/getConfig")
    public RestResponse<ExamTemplatesConfig> getConfig() {
        return RestResponse.ok(examTemplatesConfigService.getConfig());
    }
}