diff --git a/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/RecruitmentPostSearchRepositoryImpl.java b/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/RecruitmentPostSearchRepositoryImpl.java index 0c892c50..d24ec12f 100644 --- a/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/RecruitmentPostSearchRepositoryImpl.java +++ b/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/RecruitmentPostSearchRepositoryImpl.java @@ -11,7 +11,7 @@ import static synk.meeteam.domain.recruitment.recruitment_post.repository.expression.RecruitmentExpressionUtils.isBookmark; import static synk.meeteam.domain.recruitment.recruitment_post.repository.expression.RecruitmentExpressionUtils.scopeEq; import static synk.meeteam.domain.recruitment.recruitment_post.repository.expression.RecruitmentExpressionUtils.titleContains; -import static synk.meeteam.domain.recruitment.recruitment_post.repository.expression.RecruitmentExpressionUtils.writerUniversityEq; +import static synk.meeteam.domain.recruitment.recruitment_post.repository.expression.RecruitmentExpressionUtils.writerUniversityEqUser; import static synk.meeteam.domain.recruitment.recruitment_role.entity.QRecruitmentRole.recruitmentRole; import static synk.meeteam.domain.recruitment.recruitment_role_skill.entity.QRecruitmentRoleSkill.recruitmentRoleSkill; import static synk.meeteam.domain.recruitment.recruitment_tag.entity.QRecruitmentTag.recruitmentTag; @@ -73,7 +73,7 @@ private List getPostVos(Pageable pageable, SearchCondition co .leftJoin(writer).on(recruitmentPost.createdBy.eq(writer.id)) .where( scopeEq(condition.getScope()), - writerUniversityEq(writer, userDomain, condition.getScope()), + userDomain != null ? writerUniversityEqUser(writer, userDomain, condition.getScope()) : null, categoryEq(condition.getCategory()), titleContains(keyword), recruitmentPost.deleteStatus.ne(DeleteStatus.DELETED), @@ -101,7 +101,7 @@ private JPAQuery getCount(SearchCondition condition, String keyword, User .leftJoin(writer).on(recruitmentPost.createdBy.eq(writer.id)) .where( scopeEq(condition.getScope()), - writerUniversityEq(writer, userDomain, condition.getScope()), + userDomain != null ? writerUniversityEqUser(writer, userDomain, condition.getScope()) : null, categoryEq(condition.getCategory()), titleContains(keyword), recruitmentPost.deleteStatus.ne(DeleteStatus.DELETED) diff --git a/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/expression/RecruitmentExpressionUtils.java b/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/expression/RecruitmentExpressionUtils.java index 3cc904ef..41eb0d0e 100644 --- a/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/expression/RecruitmentExpressionUtils.java +++ b/src/main/java/synk/meeteam/domain/recruitment/recruitment_post/repository/expression/RecruitmentExpressionUtils.java @@ -32,8 +32,22 @@ public static BooleanExpression isClosedEq(Boolean isClosed) { return isClosed == null ? null : recruitmentPost.isClosed.eq(isClosed); } - public static BooleanExpression writerUniversityEq(QUser writer, User userDomain, Scope scope) { - return scope != Scope.ON_CAMPUS ? null : writer.university.eq(userDomain.getUniversity()); + public static BooleanExpression writerUniversityEqUser(QUser writer, User userDomain, Scope scope) { + if (scope == Scope.ON_CAMPUS) { + return isOnCampus(writer, userDomain); + } else if (scope == Scope.OFF_CAMPUS) { + return isOffCampus(); + } else { + return isOnCampus(writer, userDomain).or(isOffCampus()); + } + } + + public static BooleanExpression isOffCampus() { + return recruitmentPost.scope.eq(Scope.OFF_CAMPUS); + } + + public static BooleanExpression isOnCampus(QUser writer, User userDomain) { + return recruitmentPost.scope.eq(Scope.ON_CAMPUS).and(writer.university.eq(userDomain.getUniversity())); } public static BooleanExpression categoryEq(Category category) {