新增时间范围查询条件

develop
zhouj1203@hotmail.com 4 months ago
parent ec65450007
commit 4f3b4e6d6b

@ -38,7 +38,7 @@ public class ArtServiceImpl implements ArtService {
private Environment env;
@Override
public List<ArtElementsVo> getArtList(ArtFindDto artFindDto, HttpServletRequest request) {
List<ArtElementsVo> artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode());
List<ArtElementsVo> artElementsVos = artRepository.findPeriodById(artFindDto.getPeriodId(),"Art-"+ artFindDto.getCode(), artFindDto.getStartTime(), artFindDto.getEndTime());
List<String> classIds = artElementsVos.stream()
.map(ArtElementsVo::getClasses) // 正确的方法引用
.flatMap(List::stream) // 将内部列表扁平化

@ -14,8 +14,10 @@ public interface ArtRepository extends CosmosRepository<Art, String> {
/**
* , ,
*/
@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<ArtElementsVo> 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<ArtElementsVo> findPeriodById(@Param("periodId")String periodId, @Param("code")String code, @Param("startTime")Long startTime, @Param("endTime")Long endTime);
}

Loading…
Cancel
Save