You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
test/basic_info/StudentController.java

161 lines
7.7 KiB

package cn.iocoder.yudao.module.zhuguang.controller.admin.basic_info;
import org.springframework.web.bind.annotation.*;
import jakarta.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 jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.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.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.zhuguang.controller.admin.basic_info.vo.*;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.StudentDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.leave.AskForLeaveDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.class_check_in.CourseAttendanceRecordsDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.dormitory_check_in.DormAttendanceRecordsDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.late_signing.NightAttendanceRecDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.CourseClassDO;
import cn.iocoder.yudao.module.zhuguang.dal.dataobject.basic_info.StudentCourseClassDO;
import cn.iocoder.yudao.module.zhuguang.service.basic_info.StudentService;
@Tag(name = "管理后台 - 学生信息")
@RestController
@RequestMapping("/zhuguang/student")
@Validated
public class StudentController {
@Resource
private StudentService studentService;
@PostMapping("/create")
@Operation(summary = "创建学生信息")
@PreAuthorize("@ss.hasPermission('zhuguang:student:create')")
public CommonResult<Long> createStudent(@Valid @RequestBody StudentSaveReqVO createReqVO) {
return success(studentService.createStudent(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新学生信息")
@PreAuthorize("@ss.hasPermission('zhuguang:student:update')")
public CommonResult<Boolean> updateStudent(@Valid @RequestBody StudentSaveReqVO updateReqVO) {
studentService.updateStudent(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除学生信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('zhuguang:student:delete')")
public CommonResult<Boolean> deleteStudent(@RequestParam("id") Long id) {
studentService.deleteStudent(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得学生信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<StudentRespVO> getStudent(@RequestParam("id") Long id) {
StudentDO student = studentService.getStudent(id);
return success(BeanUtils.toBean(student, StudentRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得学生信息分页")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<PageResult<StudentRespVO>> getStudentPage(@Valid StudentPageReqVO pageReqVO) {
PageResult<StudentDO> pageResult = studentService.getStudentPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, StudentRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出学生信息 Excel")
@PreAuthorize("@ss.hasPermission('zhuguang:student:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportStudentExcel(@Valid StudentPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<StudentDO> list = studentService.getStudentPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "学生信息.xls", "数据", StudentRespVO.class,
BeanUtils.toBean(list, StudentRespVO.class));
}
// ==================== 子表(请假) ====================
@GetMapping("/ask-for-leave/list-by-student-id")
@Operation(summary = "获得请假列表")
@Parameter(name = "studentId", description = "学生ID")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<AskForLeaveDO>> getAskForLeaveListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getAskForLeaveListByStudentId(studentId));
}
// ==================== 子表(上课签到记录) ====================
@GetMapping("/course-attendance-records/list-by-student-id")
@Operation(summary = "获得上课签到记录列表")
@Parameter(name = "studentId", description = "学生的id")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<CourseAttendanceRecordsDO>> getCourseAttendanceRecordsListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getCourseAttendanceRecordsListByStudentId(studentId));
}
// ==================== 子表(宿舍签到记录) ====================
@GetMapping("/dorm-attendance-records/list-by-student-id")
@Operation(summary = "获得宿舍签到记录列表")
@Parameter(name = "studentId", description = "学生id")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<DormAttendanceRecordsDO>> getDormAttendanceRecordsListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getDormAttendanceRecordsListByStudentId(studentId));
}
// ==================== 子表(晚自习签到记录) ====================
@GetMapping("/night-attendance-rec/list-by-student-id")
@Operation(summary = "获得晚自习签到记录列表")
@Parameter(name = "studentId", description = "学生的id")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<NightAttendanceRecDO>> getNightAttendanceRecListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getNightAttendanceRecListByStudentId(studentId));
}
// ==================== 子表(课程班级) ====================
@GetMapping("/course-class/list-by-student-id")
@Operation(summary = "获得课程班级列表")
@Parameter(name = "studentId", description = "课代表ID")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<CourseClassDO>> getCourseClassListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getCourseClassListByStudentId(studentId));
}
// ==================== 子表(学生的课程班级) ====================
@GetMapping("/student-course-class/list-by-student-id")
@Operation(summary = "获得学生的课程班级列表")
@Parameter(name = "studentId", description = "学生ID")
@PreAuthorize("@ss.hasPermission('zhuguang:student:query')")
public CommonResult<List<StudentCourseClassDO>> getStudentCourseClassListByStudentId(@RequestParam("studentId") Long studentId) {
return success(studentService.getStudentCourseClassListByStudentId(studentId));
}
}