|
@@ -0,0 +1,117 @@
|
|
|
+package cn.iocoder.yudao.module.system.controller.admin.studentSelectionProject;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.supervisorSelectionSetting.vo.supervisorSelectionSettingSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.service.supervisorSelectionSetting.supervisorSelectionSettingService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.constraints.*;
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.studentSelectionProject.vo.*;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.studentSelectionProject.studentSelectionProjectDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.studentSelectionProject.studentSelectionProjectService;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 师生互选项目")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/student-selection-project")
|
|
|
+@Validated
|
|
|
+public class studentSelectionProjectController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private studentSelectionProjectService studentSelectionProjectService;
|
|
|
+ @Resource
|
|
|
+ private supervisorSelectionSettingService supervisorSelectionSettingService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建师生互选项目")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:create')")
|
|
|
+ public CommonResult<String> createStudentSelectionProject(@Valid @RequestBody studentSelectionProjectSaveReqVO createReqVO) {
|
|
|
+ if (createReqVO.getStudentStartTime().isAfter(createReqVO.getSupervisorConfirmDeadline())){
|
|
|
+ return error(1,"时间设置错误");
|
|
|
+ }
|
|
|
+ Integer projectId =studentSelectionProjectService.createStudentSelectionProject(createReqVO);
|
|
|
+ //创建初始化的导师名额设置
|
|
|
+ supervisorSelectionSettingSaveReqVO settingSaveReqVO =new supervisorSelectionSettingSaveReqVO();
|
|
|
+ if (createReqVO.getSupervisorIds()!=null||!createReqVO.getSupervisorIds().isEmpty()){
|
|
|
+ createReqVO.getSupervisorIds().forEach(supervisorId->{
|
|
|
+ settingSaveReqVO.setSupervisorId(supervisorId);
|
|
|
+ settingSaveReqVO.setProjectId(projectId);
|
|
|
+ supervisorSelectionSettingService.createSupervisorSelectionSetting(settingSaveReqVO);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return success("创建项目成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新师生互选项目")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:update')")
|
|
|
+ public CommonResult<Boolean> updateStudentSelectionProject(@Valid @RequestBody studentSelectionProjectSaveReqVO updateReqVO) {
|
|
|
+ if (updateReqVO.getStudentStartTime().isAfter(updateReqVO.getSupervisorConfirmDeadline())){
|
|
|
+ return error(1,"时间设置错误");
|
|
|
+ }
|
|
|
+ studentSelectionProjectService.updateStudentSelectionProject(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除师生互选项目")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:delete')")
|
|
|
+ public CommonResult<Boolean> deleteStudentSelectionProject(@RequestParam("id") Integer id) {
|
|
|
+ studentSelectionProjectService.deleteStudentSelectionProject(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得师生互选项目")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:query')")
|
|
|
+ public CommonResult<studentSelectionProjectRespVO> getStudentSelectionProject(@RequestParam("id") Integer id) {
|
|
|
+ studentSelectionProjectDO studentSelectionProject = studentSelectionProjectService.getStudentSelectionProject(id);
|
|
|
+ return success(BeanUtils.toBean(studentSelectionProject, studentSelectionProjectRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得师生互选项目分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:query')")
|
|
|
+ public CommonResult<PageResult<studentSelectionProjectRespVO>> getStudentSelectionProjectPage(@Valid studentSelectionProjectPageReqVO pageReqVO) {
|
|
|
+ PageResult<studentSelectionProjectDO> pageResult = studentSelectionProjectService.getStudentSelectionProjectPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, studentSelectionProjectRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出师生互选项目 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('system:student-selection-project:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportStudentSelectionProjectExcel(@Valid studentSelectionProjectPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<studentSelectionProjectDO> list = studentSelectionProjectService.getStudentSelectionProjectPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "师生互选项目.xls", "数据", studentSelectionProjectRespVO.class,
|
|
|
+ BeanUtils.toBean(list, studentSelectionProjectRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|