|
|
|
|
@ -7,11 +7,14 @@ import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.course.common.R;
|
|
|
|
|
import com.ruoyi.course.domain.Student;
|
|
|
|
|
import com.ruoyi.course.domain.dto.StudentQueryDTO;
|
|
|
|
|
import com.ruoyi.course.domain.vo.StudentQueryVO;
|
|
|
|
|
import com.ruoyi.course.enums.GradeEnum;
|
|
|
|
|
import com.ruoyi.course.service.IStudentService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@ -30,6 +33,7 @@ import java.util.List;
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/course/student")
|
|
|
|
|
@Api(tags = "学生管理")
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class StudentController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
@ -86,38 +90,40 @@ public class StudentController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation("查询所有学生")
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public TableDataInfo listStudents(Student student) {
|
|
|
|
|
public TableDataInfo listStudents(StudentQueryDTO queryDTO) {
|
|
|
|
|
LambdaQueryWrapper<Student> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
|
|
|
// 处理年级条件
|
|
|
|
|
try {
|
|
|
|
|
GradeEnum gradeEnum = queryDTO.getGradeEnum();
|
|
|
|
|
if (gradeEnum != null && gradeEnum != GradeEnum.ALL) {
|
|
|
|
|
wrapper.eq(Student::getGrade, gradeEnum);
|
|
|
|
|
}
|
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
|
log.warn("年级参数转换失败: {}", queryDTO.getGrade());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 其他条件
|
|
|
|
|
if (StringUtils.hasText(queryDTO.getStudentNo())) {
|
|
|
|
|
wrapper.like(Student::getStudentNo, queryDTO.getStudentNo());
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasText(queryDTO.getName())) {
|
|
|
|
|
wrapper.like(Student::getName, queryDTO.getName());
|
|
|
|
|
}
|
|
|
|
|
if (queryDTO.getClassId() != null) {
|
|
|
|
|
wrapper.eq(Student::getClassId, queryDTO.getClassId());
|
|
|
|
|
}
|
|
|
|
|
if (queryDTO.getStatus() != null) {
|
|
|
|
|
wrapper.eq(Student::getStatus, queryDTO.getStatus());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wrapper.orderByDesc(Student::getCreateTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startPage();
|
|
|
|
|
// // 创建查询条件
|
|
|
|
|
// LambdaQueryWrapper<Student> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
//
|
|
|
|
|
// // 添加查询条件(非空判断)
|
|
|
|
|
// if (StringUtils.hasText(student.getStudentNo())) {
|
|
|
|
|
// wrapper.like(Student::getStudentNo, student.getStudentNo());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (StringUtils.hasText(student.getName())) {
|
|
|
|
|
// wrapper.like(Student::getName, student.getName());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (student.getClassId() != null) {
|
|
|
|
|
// wrapper.eq(Student::getClassId, student.getClassId());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (StringUtils.hasText(String.valueOf(student.getGrade()))) {
|
|
|
|
|
// wrapper.eq(Student::getGrade, student.getGrade());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (student.getStatus() != null) {
|
|
|
|
|
// wrapper.eq(Student::getStatus, student.getStatus());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 按创建时间倒序
|
|
|
|
|
// wrapper.orderByDesc(Student::getCreateTime);
|
|
|
|
|
// List<Student> list = studentService.list(wrapper);
|
|
|
|
|
List<Student> list = studentService.list();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Student> list = studentService.list(wrapper);
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|