Skip to content

Commit 5232aa8

Browse files
Merge pull request #204 from prgrms-web-devcourse-final-project/refactor/hide-draft-in-inbox-detail(WR9-121)
refactor: 내 편지함에서 임시저장된 편지 안보이게 쿼리 수정 (WR9-121)
2 parents 75c63d5 + 2150e5b commit 5232aa8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/main/java/io/crops/warmletter/domain/letter/repository/LetterMatchingRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public interface LetterMatchingRepository extends JpaRepository<LetterMatching,
4141
"COALESCE(COUNT(l), 0)" +
4242
") " +
4343
"FROM LetterMatching lm " +
44-
"LEFT JOIN Letter l ON lm.id = l.matchingId AND (l.status = 'DELIVERED' OR l.writerId = :myId) AND l.isActive = true " +
44+
"LEFT JOIN Letter l ON lm.id = l.matchingId AND (l.status = 'DELIVERED' OR (l.writerId = :myId AND l.status != 'SAVED')) AND l.isActive = true " +
4545
"JOIN Member m ON (CASE WHEN lm.firstMemberId = :myId THEN lm.secondMemberId ELSE lm.firstMemberId END) = m.id " +
4646
"WHERE (lm.firstMemberId = :myId OR lm.secondMemberId = :myId) " +
4747
"GROUP BY lm.id, m.zipCode, lm.isActive " +

src/main/java/io/crops/warmletter/domain/letter/repository/LetterRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public interface LetterRepository extends JpaRepository<Letter, Long> {
3838

3939
Optional<Letter> findByIdAndWriterId(Long letterId, Long writerId);
4040

41-
@Query("SELECT l FROM Letter l WHERE l.matchingId = :matchingId AND l.isActive = true " +
41+
@Query("SELECT l FROM Letter l WHERE l.matchingId = :matchingId " +
42+
"AND l.isActive = true " +
4243
"AND (l.writerId = :currentUserId OR l.status = 'DELIVERED') " +
44+
"AND (l.writerId != :currentUserId OR l.status != 'SAVED') " +
4345
"ORDER BY l.id DESC")
4446
Page<Letter> findDeliveredOrMyLettersByMatchingId(
4547
@Param("matchingId") Long matchingId,

0 commit comments

Comments
 (0)