해당 게시글은 개인 프로젝트인 "광고 관리 플랫폼 대행사 센터 제작" 중
#112 "광고 관리 페이지 (광고주 리스트) 수정 및 통계 기능 구현" 이슈를 다루고 있습니다.
Projections.fields
를 통해 필드에 직접 값을 주입하는 방식 선택 public List<PerformanceStatisticsDto> findClientUserSpendTotalStatisticsDefault(
@Param("startDate") LocalDate startDate,
@Param("lastDate") LocalDate lastDate
) {
List<PerformanceStatisticsDto> results = jpaQueryFactory
.select(Projections.fields(PerformanceStatisticsDto.class,
performance.spend.sum().as("spend")
))
.from(performance)
.leftJoin(performance.creative, creative)
.where(
performance.createdAt.between(startDate, lastDate),
creative.deleted.eq(false),
)
.fetch();
for (PerformanceStatisticsDto result : results) {
Long spend = result.getSpend();
result.setSpendIndicator(spend); // spend 세팅용 메소드
result.setStartDateAndLastDate(startDate, lastDate);
}
return results;
}
}