Skip to content

Commit 2035686

Browse files
authored
refactor : BooleanBuilder 조합 위치 변경 (#138)
1 parent 14512d1 commit 2035686

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/problem/ProblemQueryRepositoryImpl.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ public Page<Problem> searchByCondition(Pageable pageable, ProblemSearchCondition
3737

3838
builder.and(problem.isDeleted.isFalse());
3939

40-
JPAQuery<Problem> query = jpaQueryFactory
41-
.selectDistinct(problem)
42-
.from(problem)
43-
.leftJoin(problemCategory).on(problem.eq(problemCategory.problem))
44-
.leftJoin(problemCategory.category, category)
45-
.where(builder);
46-
4740
// 카테고리 필터링
4841
if (searchCondition.category() != null) {
4942
builder.and(category.code.eq(searchCondition.category())
@@ -55,6 +48,15 @@ public Page<Problem> searchByCondition(Pageable pageable, ProblemSearchCondition
5548
builder.and(problem.difficulty.eq(Difficulty.valueOf(searchCondition.difficulty())));
5649
}
5750

51+
JPAQuery<Problem> query = jpaQueryFactory
52+
.selectDistinct(problem)
53+
.from(problem)
54+
.leftJoin(problemCategory).on(problem.eq(problemCategory.problem))
55+
.leftJoin(problemCategory.category, category)
56+
.where(builder);
57+
58+
59+
5860
List<Problem> content = query
5961
.offset(pageable.getOffset())
6062
.limit(pageable.getPageSize())

0 commit comments

Comments
 (0)