File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
src/main/java/com/somemore Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -33,4 +33,8 @@ public void prePersist() {
3333 this .deleted = false ;
3434 }
3535 }
36+
37+ public void markAsDeleted () {
38+ this .deleted = true ;
39+ }
3640}
Original file line number Diff line number Diff line change 11package com .somemore .recruitboard .repository ;
22
3+ import com .querydsl .core .types .dsl .BooleanExpression ;
34import com .querydsl .jpa .impl .JPAQueryFactory ;
5+ import com .somemore .recruitboard .domain .QRecruitBoard ;
46import com .somemore .recruitboard .domain .RecruitBoard ;
57import java .util .Optional ;
68import lombok .RequiredArgsConstructor ;
@@ -25,13 +27,23 @@ public RecruitBoard saveAndFlush(RecruitBoard recruitBoard) {
2527
2628 @ Override
2729 public Optional <RecruitBoard > findById (Long id ) {
28- return recruitBoardJpaRepository .findById (id );
29- }
30+ QRecruitBoard recruitBoard = QRecruitBoard .recruitBoard ;
31+
32+ RecruitBoard result = queryFactory
33+ .selectFrom (recruitBoard )
34+ .where (isNotDeleted ().and (recruitBoard .id .eq (id )))
35+ .fetchOne ();
3036
37+ return Optional .ofNullable (result );
38+ }
39+
3140 @ Override
3241 public void deleteAllInBatch () {
3342 recruitBoardJpaRepository .deleteAllInBatch ();
3443 }
3544
36-
45+ private BooleanExpression isNotDeleted () {
46+ QRecruitBoard recruitBoard = QRecruitBoard .recruitBoard ;
47+ return recruitBoard .deleted .eq (false );
48+ }
3749}
You can’t perform that action at this time.
0 commit comments