Skip to content

Commit

Permalink
Merge pull request #296 from team9502/dev
Browse files Browse the repository at this point in the history
fix: 기업 전체조회 - 조인X [배포]
  • Loading branch information
EUNCHAEv1006 authored Jul 2, 2024
2 parents b7179a9 + 9adb48e commit a21ca8c
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 a21ca8c

Please sign in to comment.