From 4f3b4e6d6b9c91ff0f6b9cfb99320cefe6d1dc1a Mon Sep 17 00:00:00 2001 From: "zhouj1203@hotmail.com" Date: Thu, 5 Sep 2024 17:54:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=B6=E9=97=B4=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/service/impl/ArtServiceImpl.java | 2 +- src/main/java/cn/teammodel/repository/ArtRepository.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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); }