diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java index 7318d60..fb614ca 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java @@ -17,10 +17,12 @@ import cn.teammodel.utils.GroupUtil; import cn.teammodel.utils.SchoolDateUtil; import com.azure.spring.data.cosmos.core.query.CosmosPageRequest; import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.data.domain.Slice; +import org.springframework.data.domain.SliceImpl; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -136,7 +138,13 @@ public class TeacherServiceImpl implements TeacherService { Map countByWeek = SchoolDateUtil.createEmptyWeekMap(totalWeek); do { - slice = lessonRecordRepository.findAllByAcademicYearId(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getTmdId(),pageRequest); + if(StringUtils.isNotEmpty(teacherDto.getGrade())) { + slice = lessonRecordRepository.findAllByGrade(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getGrade(),pageRequest); + } else if(StringUtils.isNotEmpty(teacherDto.getTmdId())) { + slice = lessonRecordRepository.findAllByAcademicYearId(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), teacherDto.getTmdId(),pageRequest); + } else { + slice = lessonRecordRepository.findAll(String.format(PK.PK_LESSON_RECORD, teacherDto.getCode()), pageRequest); + } List content = slice.getContent(); if (ObjectUtils.isEmpty(content)) { break; diff --git a/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java b/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java index 123117d..d27bba9 100644 --- a/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java +++ b/src/main/java/cn/teammodel/model/dto/admin/teacher/TeacherDto.java @@ -16,4 +16,6 @@ public class TeacherDto { @ApiModelProperty("学段Id") public String periodId; public Integer year; + @ApiModelProperty("年级") + public String grade; } diff --git a/src/main/java/cn/teammodel/repository/LessonRecordRepository.java b/src/main/java/cn/teammodel/repository/LessonRecordRepository.java index 49f0c0e..8ee424d 100644 --- a/src/main/java/cn/teammodel/repository/LessonRecordRepository.java +++ b/src/main/java/cn/teammodel/repository/LessonRecordRepository.java @@ -21,5 +21,9 @@ public interface LessonRecordRepository extends CosmosRepository404 and c.tmdid = @tmdId ") Slice findAllByAcademicYearId(String code, String tmdId,Pageable pageable); + @Query("select * from LessonRecord as c where c.code = @code and c.expire<=0 and c.status<>404 and array_contains(c.grade,@grade) ") + Slice findAllByGrade(String code, String grade,Pageable pageable); + @Query("select * from LessonRecord as c where c.code = @code and c.expire<=0 and c.status<>404 ") + Slice findAll(String code,Pageable pageable); }