From a9c6c6a49930d48e624c5f547d57789723eef163 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Tue, 26 Nov 2024 16:24:52 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=AF=8F=E5=91=A8=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E8=AF=BE=E4=BE=8B=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/TeacherServiceImpl.java | 10 +++++++++- .../teammodel/model/dto/admin/teacher/TeacherDto.java | 2 ++ .../teammodel/repository/LessonRecordRepository.java | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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); }