diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java index d31dd58..e0755e7 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/ArtServiceImpl.java @@ -38,7 +38,7 @@ public class ArtServiceImpl implements ArtService { private Environment env; @Override public List getArtList(ArtFindDto artFindDto, HttpServletRequest request) { - List artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode()); + List artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode(), artFindDto.getStartTime(), artFindDto.getEndTime()); List classIds = artElementsVos.stream() .map(ArtElementsVo::getClasses) // 正确的方法引用 .flatMap(List::stream) // 将内部列表扁平化 diff --git a/src/main/java/cn/teammodel/repository/ArtRepository.java b/src/main/java/cn/teammodel/repository/ArtRepository.java index 072f9af..b2552de 100644 --- a/src/main/java/cn/teammodel/repository/ArtRepository.java +++ b/src/main/java/cn/teammodel/repository/ArtRepository.java @@ -14,8 +14,10 @@ public interface ArtRepository extends CosmosRepository { /** * 动态投影, 查询还是要将所有的值查出来,类的动态查询不能嵌套 */ - @Query("select s.id,s.name,s.classes,s.startTime,s.endTime,s.subjects,s.progress,s.settings from Art as s where s.period.id = @periodId and s.code = @code") - List findPeriodById(@Param("periodId")String periodId, @Param("code")String code); + @Query("select s.id,s.name,s.classes,s.startTime,s.endTime,s.subjects,s.progress,s.settings from Art as s where s.period.id = @periodId and s.code = @code " + + "and (IS_NULL(@startTime) or s.startTime >= @startTime) " + + "and (IS_NULL(@endTime) or s.startTime < @endTime) ") + List findPeriodById(@Param("periodId")String periodId, @Param("code")String code, @Param("startTime")Long startTime, @Param("endTime")Long endTime); }