Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 기업 전체조회 - 조인X #295

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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