Skip to content

Commit 4601f0e

Browse files
committed
feat: 논리 삭제 반영
1 parent 0e5e3bf commit 4601f0e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main/java/com/somemore/global/common/BaseEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/main/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImpl.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.somemore.recruitboard.repository;
22

3+
import com.querydsl.core.types.dsl.BooleanExpression;
34
import com.querydsl.jpa.impl.JPAQueryFactory;
5+
import com.somemore.recruitboard.domain.QRecruitBoard;
46
import com.somemore.recruitboard.domain.RecruitBoard;
57
import java.util.Optional;
68
import 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
}

0 commit comments

Comments
 (0)