-
Notifications
You must be signed in to change notification settings - Fork 1
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
[REFACTOR] 검색 디렉토리 분리 및 쿼리 리팩토링 #341
base: main
Are you sure you want to change the base?
Changes from all commits
7a6b4b5
dafef89
bdc5ed3
666050f
6c22867
d2f91f5
ebb486d
0838c3e
3796e6b
c9c9b30
f3296ed
fe6faf5
b8cf776
26997f6
a989a01
6399ad4
7a75784
d810858
21bbe8d
1d18ef3
defbe5a
6fe8f0f
493f1b7
b9a1f57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.somemore.domains.center.repository.center; | ||
|
||
import com.querydsl.core.types.Path; | ||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
@@ -66,7 +67,27 @@ public void deleteAllInBatch() { | |
centerJpaRepository.deleteAllInBatch(); | ||
} | ||
|
||
@Override | ||
public String findNameById(UUID id) { | ||
return findDynamicField(id, center.name) | ||
.orElse(null); | ||
} | ||
|
||
private static BooleanExpression isNotDeleted() { | ||
return center.deleted.isFalse(); | ||
} | ||
|
||
private <T> Optional<T> findDynamicField(UUID id, Path<T> field) { | ||
|
||
return Optional.ofNullable( | ||
queryFactory | ||
.select(field) | ||
.from(center) | ||
.where( | ||
center.id.eq(id), | ||
isNotDeleted() | ||
) | ||
.fetchOne() | ||
); | ||
} | ||
Comment on lines
+80
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋아요! 사실 저번에 동적 쿼리를 위한 헬퍼 메서드 만들다가 조건 개수나 정렬, 페이징 같은 것 때문에 시간이 부족해서 포기했었는데 이번 기회에 조금 더 생각해 볼 수 있을 것 같습니다~ |
||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
|
||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@Entity | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 신기하네요 생각하지 못했던 방법이라 감탄했습니다