Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,18 @@ Page<MyBook> searchMyBooksWithoutMemberId(
LEFT JOIN m.book b
LEFT JOIN m.bookLogs bl
WHERE
(bl.booklogType = 'IMPRESSION' OR bl.booklogType IS NULL)
AND m.isReading = true
m.isReading = true
AND m.status = 'ACTIVE'
""",
countQuery = """
SELECT COUNT(m) FROM MyBook m
LEFT JOIN m.book b
LEFT JOIN m.bookLogs bl
WHERE
(bl.booklogType = 'IMPRESSION' OR bl.booklogType IS NULL)
AND m.isReading = true
m.isReading = true
AND m.status = 'ACTIVE'
"""
)
List<MyBook> findByMemberIdAndIsReadingWithoutMemberId();
List<MyBook> findAllActiveReadingBooks();

}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public InProgressBooksRes searchInProgressBooks() {
//UUID memberId = request.getMemberId();
//UUID memberId = UUID.fromString("d290f1ee-6c54-4b01-90e6-d701748f0851");

List<MyBook> myBooks = myBookRepository.findByMemberIdAndIsReadingWithoutMemberId();
List<MyBook> myBooks = myBookRepository.findAllActiveReadingBooks();

List<InProgressBooksRes.BookDto> bookDtos = myBooks.stream()
.map(myBook -> {
Expand All @@ -209,13 +209,19 @@ public InProgressBooksRes searchInProgressBooks() {
.map(author -> author.getWriter().getWriterName())
.collect(Collectors.joining(", ")); // 여러 작가면 ,로 구분

String firstImpression = myBook.getBookLogs().stream()
.filter(bookLog -> bookLog.getBooklogType().equals("IMPRESSION"))
.findFirst()
.map(BookLog::getContent)
.orElse(null);

return InProgressBooksRes.BookDto.builder()
.mybookId(myBook.getMybookId())
.title(book.getTitle())
.author(authorNames)
.coverImage(book.getCoverImage())
.progress(String.format("%d", myBook.getNowPage() * 100 / book.getPage()))
.firstImpression(myBook.getBookLogs().isEmpty() ? null : myBook.getBookLogs().get(0).getContent())
.firstImpression(firstImpression)
.recentEdit(String.valueOf(myBook.getUpdatedAt()))
.build();
})
Expand Down