课程查询相关代码优化

master
Alan 5 months ago
parent 7c0c549928
commit 59af410cf8
  1. 8
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java

@ -186,10 +186,10 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
private PageDTO<CoursesVO> queryForAdmin(CourseQuery courseQuery) {
Page<Courses> page = courseQuery.toMpPageDefaultSortByCreateTime();
Page<Courses> p = lambdaQuery()
.like(courseQuery.getName() != null, Courses::getName, courseQuery.getName())
.eq(courseQuery.getCategory() != null, Courses::getCategory, courseQuery.getCategory())
.eq(courseQuery.getNature() != null, Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null, Courses::getAssessmenttype, courseQuery.getAssessmenttype())
.like(courseQuery.getName() != null && !courseQuery.getName().isEmpty(), Courses::getName, courseQuery.getName())
.eq(courseQuery.getCategory() != null && !courseQuery.getCategory().isEmpty(), Courses::getCategory, courseQuery.getCategory())
.eq(courseQuery.getNature() != null && !courseQuery.getNature().isEmpty(), Courses::getNature, courseQuery.getNature())
.eq(courseQuery.getAssessmenttype() != null &&!courseQuery.getAssessmenttype().isEmpty(), Courses::getAssessmenttype, courseQuery.getAssessmenttype())
.apply(courseQuery.getTeacher() != null && !courseQuery.getTeacher().isEmpty(), "FIND_IN_SET({0}, teacher)", courseQuery.getTeacher())
.page(page);
return PageDTO.of(p, CoursesVO.class);

Loading…
Cancel
Save