-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,025 additions
and
253 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
be/src/main/java/movlit/be/book/application/converter/BookCommentLikeCountConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package movlit.be.book.application.converter; | ||
|
||
import movlit.be.book.domain.BookCommentLike; | ||
import movlit.be.book.domain.BookCommentLikeCount; | ||
import movlit.be.book.domain.entity.BookCommentLikeCountEntity; | ||
import movlit.be.book.domain.entity.BookCommentLikeEntity; | ||
import movlit.be.member.application.converter.MemberConverter; | ||
|
||
public class BookCommentLikeCountConverter { | ||
private BookCommentLikeCountConverter() { | ||
// TODO : 공통적인 예외처리 등록해주기 | ||
} | ||
|
||
|
||
// Domain -> Entity | ||
public static BookCommentLikeCountEntity toEntity(BookCommentLikeCount bookCommentLikeCount) { | ||
if(bookCommentLikeCount == null) | ||
return null; | ||
else | ||
return BookCommentLikeCountEntity.builder() | ||
.bookCommentLikeCountId(bookCommentLikeCount.getBookCommentLikeCountId()) | ||
.bookCommentEntity(BookCommentConverter.toEntity(bookCommentLikeCount.getBookComment())) | ||
.count(bookCommentLikeCount.getCount()) | ||
.build(); | ||
} | ||
|
||
// Entity -> Domain | ||
public static BookCommentLikeCount toDomain(BookCommentLikeCountEntity bookCommentLikeCountEntity) { | ||
if (bookCommentLikeCountEntity == null) | ||
return null; | ||
else | ||
return BookCommentLikeCount.builder() | ||
.bookCommentLikeCountId(bookCommentLikeCountEntity.getBookCommentLikeCountId()) | ||
.bookComment(BookCommentConverter.toDomain(bookCommentLikeCountEntity.getBookCommentEntity())) | ||
.count(bookCommentLikeCountEntity.getCount()) | ||
.build(); | ||
} | ||
|
||
} |
54 changes: 0 additions & 54 deletions
54
be/src/main/java/movlit/be/book/application/converter/service/BookCommentReadService.java
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
be/src/main/java/movlit/be/book/application/service/BookCommentReadService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package movlit.be.book.application.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import movlit.be.book.domain.Book; | ||
import movlit.be.book.domain.BookComment; | ||
import movlit.be.book.domain.BookCommentLike; | ||
import movlit.be.book.domain.repository.BookCommentLikeCountRepository; | ||
import movlit.be.book.presentation.dto.BookCommentResponseDto; | ||
import movlit.be.book.domain.repository.BookCommentLikeRepository; | ||
import movlit.be.book.domain.repository.BookCommentRepository; | ||
import movlit.be.common.util.ids.BookCommentId; | ||
import movlit.be.common.util.ids.BookId; | ||
import movlit.be.common.util.ids.MemberId; | ||
import movlit.be.member.domain.Member; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BookCommentReadService { | ||
public static final int PAGE_SIZE = 10; | ||
|
||
|
||
private final BookCommentRepository bookCommentRepository; | ||
private final BookCommentLikeRepository bookCommentLikeRepository; | ||
private final BookCommentLikeCountRepository bookCommentLikeCountRepository; | ||
|
||
// 리뷰 리스트 | ||
public Slice<BookCommentResponseDto> getPagedBookComments(BookId bookId, MemberId memberId, Pageable pageable) { | ||
Slice<BookCommentResponseDto> bookCommentPage = null; | ||
if(memberId == null) | ||
bookCommentPage = bookCommentRepository.findByBookId(bookId, pageable); | ||
else | ||
bookCommentPage = bookCommentRepository.findByBookIdAndMemberId(bookId, memberId, pageable); | ||
|
||
System.out.println("$$$$$$$ 리뷰리스트 : " ); | ||
for (BookCommentResponseDto comment : bookCommentPage.getContent()) { | ||
// 각 BookCommentResponseDto의 내용 출력 | ||
System.out.println("Comment TEXT: " + comment.getComment()); | ||
System.out.println("Comment LIKED: " + comment.isLiked()); | ||
System.out.println("COMMENTS NUM" + comment.getAllCommentsCount()); | ||
// 필요에 따라 추가 속성을 출력할 수 있습니다. | ||
} | ||
|
||
return bookCommentPage; | ||
} | ||
|
||
// 내가 작성한 도서 리뷰 찾기 | ||
public BookComment findByMemberAndBook(Member member, Book book) { | ||
return bookCommentRepository.findByMemberAndBook(member, book); | ||
|
||
} | ||
|
||
public BookComment findByBookCommentId(BookCommentId bookCommentId) { | ||
return bookCommentRepository.findByBookCommentId(bookCommentId); | ||
} | ||
|
||
|
||
// 댓글 좋아요 갯수 | ||
public int countLikesByCommentId(BookCommentId bookCommentId){ | ||
return bookCommentLikeCountRepository.countLikeByCommentId(bookCommentId); | ||
} | ||
|
||
// 해당 댓글 나의 좋아요 여부 | ||
public boolean isLikedByComment(BookComment bookComment, Member member){ | ||
if(bookCommentLikeRepository.findByBookCommentAndMember(bookComment, member) != null) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erter/service/BookDetailWriteService.java → ...ation/service/BookDetailWriteService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
be/src/main/java/movlit/be/book/domain/BookCommentLikeCount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package movlit.be.book.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import movlit.be.book.domain.entity.BookCommentEntity; | ||
import org.hibernate.annotations.ColumnDefault; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
@ToString | ||
@Builder | ||
public class BookCommentLikeCount { | ||
|
||
private Long bookCommentLikeCountId; | ||
private BookComment bookComment; | ||
private int count; // 해당 리뷰의 "좋아요"(like) 갯수 | ||
private Long version; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.