Skip to content

Commit

Permalink
fix: 기업 전체조회
Browse files Browse the repository at this point in the history
  • Loading branch information
EUNCHAEv1006 committed Jul 2, 2024
1 parent f31f701 commit 81fd426
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import team9502.sinchulgwinong.domain.scrap.entity.QCpUserScrap;

import java.util.List;
import java.util.Optional;

@Repository
public class CompanyUserRepositoryImpl implements CompanyUserRepositoryCustom {
Expand Down Expand Up @@ -68,18 +69,21 @@ public Page<CompanyUser> findAllWithFilters(String sort, Float minRating, Float
query.orderBy(companyUser.cpUserId.asc()); // 기본 정렬 조건
}

// 총 개수 계산을 위한 쿼리 생성 및 실행
long total = query.fetchCount();

// 쿼리 디버깅을 위한 로그
logger.info("쿼리 실행 조건 - sort: {}, minRating: {}, maxRating: {}, pageable: {}, total: {}", sort, minRating, maxRating, pageable, total);

// 페이지 데이터 조회
List<CompanyUser> results = query
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();

// 총 개수 계산
long total = Optional.ofNullable(queryFactory
.select(companyUser.count())
.from(companyUser)
.fetchOne()).orElse(0L);

// 쿼리 디버깅을 위한 로그
logger.info("쿼리 실행 조건 - sort: {}, minRating: {}, maxRating: {}, pageable: {}, total: {}", sort, minRating, maxRating, pageable, total);

// 결과 디버깅을 위한 로그
logger.info("쿼리 결과 - results size: {}, pageable: {}", results.size(), pageable);

Expand Down

0 comments on commit 81fd426

Please sign in to comment.