Skip to content

Commit

Permalink
fix: 기업 전체조회 - 조인X
Browse files Browse the repository at this point in the history
  • Loading branch information
EUNCHAEv1006 committed Jul 2, 2024
1 parent 81fd426 commit 549f1ce
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.stereotype.Repository;
import team9502.sinchulgwinong.domain.companyUser.entity.CompanyUser;
import team9502.sinchulgwinong.domain.companyUser.entity.QCompanyUser;
import team9502.sinchulgwinong.domain.jobBoard.entity.QJobBoard;
import team9502.sinchulgwinong.domain.scrap.entity.QCpUserScrap;

import java.util.List;
Expand All @@ -30,14 +29,10 @@ public CompanyUserRepositoryImpl(EntityManager entityManager) {
@Override
public Page<CompanyUser> findAllWithFilters(String sort, Float minRating, Float maxRating, Pageable pageable) {
QCompanyUser companyUser = QCompanyUser.companyUser;
QCpUserScrap cpUserScrap = QCpUserScrap.cpUserScrap;
QJobBoard jobBoard = QJobBoard.jobBoard;

// 기본 쿼리 구성
JPAQuery<CompanyUser> query = queryFactory
.selectFrom(companyUser)
.leftJoin(cpUserScrap).on(cpUserScrap.companyUser.eq(companyUser))
.leftJoin(jobBoard).on(jobBoard.companyUser.eq(companyUser));
.selectFrom(companyUser);

// 필터 조건 적용
if (minRating != null && maxRating != null) {
Expand All @@ -50,15 +45,9 @@ public Page<CompanyUser> findAllWithFilters(String sort, Float minRating, Float
case "reviewsDesc":
query.orderBy(companyUser.reviewCount.desc());
break;
case "jobPostingsDesc":
query.orderBy(jobBoard.count().desc());
break;
case "viewsDesc":
query.orderBy(companyUser.viewCount.desc());
break;
case "scrapsDesc":
query.orderBy(cpUserScrap.count().desc());
break;
case "createdAtDesc":
query.orderBy(companyUser.createdAt.desc());
break;
Expand Down

0 comments on commit 549f1ce

Please sign in to comment.