Skip to content

Commit

Permalink
[FIX] 로그인 여부, 범위에 따라 학교 구분 (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goder-0 authored May 13, 2024
1 parent cec18c4 commit 82dcfd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +73,7 @@ private List<RecruitmentPostVo> 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),
Expand Down Expand Up @@ -101,7 +101,7 @@ private JPAQuery<Long> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 82dcfd2

Please sign in to comment.