Skip to content

Commit e6423b7

Browse files
committed
🐛 기록 조회 조건 에러 해결
- 책장 조회시 status 기준 추가 - 마이페이지 통계시 총읽은책에 status 기준 추가 - 기본서재명 오타 수정
1 parent 71ddb30 commit e6423b7

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/main/java/com/boggle_boggle/bbegok/enums/LibraryByStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@RequiredArgsConstructor
88
public enum LibraryByStatus {
99
reading("읽는 중인 책"),
10-
pending("읽고 있는 책"),
10+
pending("읽고 싶은 책"),
1111
completed("다 읽은 책"),
1212
all("전체보기");
1313

src/main/java/com/boggle_boggle/bbegok/repository/ReadingRecordRepository.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ public interface ReadingRecordRepository extends JpaRepository<ReadingRecord, Lo
2222

2323
Optional<ReadingRecord> findByreadingRecordSeqAndUserOrderByReadingRecordSeq(Long id, User user);
2424

25+
@Query(value = """
26+
SELECT COUNT(DISTINCT r)
27+
FROM ReadingRecord r
28+
JOIN r.readDateList rd
29+
WHERE r.user = :user
30+
AND rd.status = :status
31+
""")
32+
int findTotalyReadingCnt(
33+
@Param("user") User user,
34+
@Param("status") ReadStatus status
35+
);
2536

2637
@Query(value = """
2738
SELECT COUNT(DISTINCT r)
@@ -46,11 +57,14 @@ int findMonthlyReadingCnt(
4657
AND r.isBooksVisible = true
4758
AND (:year IS NULL OR EXTRACT(YEAR FROM rd.endReadDate) = :year)
4859
AND (:month IS NULL OR EXTRACT(MONTH FROM rd.endReadDate) = :month)
60+
AND rd.status = :status
4961
""")
5062
List<ReadingRecord> findBooksByUserAndReadDate(
5163
@Param("user") User user,
5264
@Param("year") Integer year,
53-
@Param("month") Integer month
65+
@Param("month") Integer month,
66+
@Param("status") ReadStatus status
67+
5468
);
5569

5670

src/main/java/com/boggle_boggle/bbegok/service/LibraryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public LibraryBookListResponse findAll(int pageNum, String userId, int pageSize,
136136

137137
public BookShelfResponse findBookshelfByEndDate(Integer year, Integer month, String userId) {
138138
User user = getUser(userId);
139-
List<ReadingRecord> booksPage = readingRecordRepository.findBooksByUserAndReadDate(user, year, month);
139+
List<ReadingRecord> booksPage = readingRecordRepository.findBooksByUserAndReadDate(user, year, month, ReadStatus.completed);
140140
return BookShelfResponse.fromPage(booksPage);
141141
}
142142
}

src/main/java/com/boggle_boggle/bbegok/service/MyPageService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public User getUser(String userId) {
3636
public MyPageResponse getMyPage(String userId) {
3737
User user = getUser(userId);
3838
//총 읽은 권수 - ReadingRecord 갯수
39-
int totalReadingCnt = readingRecordRepository.findByUser(user).size();
39+
int totalReadingCnt = readingRecordRepository.findTotalyReadingCnt(user, ReadStatus.completed);
4040
//이번달 읽은 권수 - 이번달에 다 읽은 ReadingRecord 갯수(상태 상관없이 둘다?)
4141
int monthlyReadingCnt = readingRecordRepository.findMonthlyReadingCnt(user, ReadStatus.completed);
4242
//작성한 독서노트 - 작성한 모든 독서노트 갯수

0 commit comments

Comments
 (0)