Skip to content

Commit

Permalink
feat: Comment 사용자 ID 추가 (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
AHNYUNKI committed May 28, 2024
1 parent 4068c53 commit 925c878
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ public class CommentFindAllResponse {
private Long commentLikeCount;
private List<String> commentImages = new ArrayList<>();
private LocalDateTime registeredDateTime;
private Long creatorId;

@Builder
private CommentFindAllResponse(Long commentId, String userName, String profileImage, String content,
Long commentLikeCount, List<String> commentImages,
LocalDateTime registeredDateTime) {
LocalDateTime registeredDateTime, Long creatorId) {
this.commentId = commentId;
this.userName = userName;
this.profileImage = profileImage;
this.content = content;
this.commentLikeCount = commentLikeCount;
this.commentImages = commentImages;
this.registeredDateTime = registeredDateTime;
this.creatorId = creatorId;
}

public static CommentFindAllResponse of(CommentQueryResponse comment, List<CommentImage> commentImages) {
Expand All @@ -45,6 +47,7 @@ public static CommentFindAllResponse of(CommentQueryResponse comment, List<Comme
.commentLikeCount(comment.getCommentLikeCount())
.commentImages(extractCommentImages(commentImages))
.registeredDateTime(comment.getRegisteredDateTime().withNano(0))
.creatorId(comment.getCreatorId())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ public class CommentQueryResponse {
private String content;
private Long commentLikeCount;
private LocalDateTime registeredDateTime;
private Long creatorId;

@Builder
@QueryProjection
public CommentQueryResponse(Long commentId, String userName, String profileImage, String content,
Long commentLikeCount,
LocalDateTime registeredDateTime) {
LocalDateTime registeredDateTime, Long creatorId) {
this.commentId = commentId;
this.userName = userName;
this.profileImage = profileImage;
this.content = content;
this.commentLikeCount = commentLikeCount;
this.registeredDateTime = registeredDateTime;
this.creatorId = creatorId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public List<CommentQueryResponse> findAllComments(Long talkRoomId) {
user.profileImage,
comment.content,
commentLike.count().as("commentLiKeCount"),
comment.registeredDateTime
comment.registeredDateTime,
user.id.as("creatorId")
))
.from(comment)
.join(comment.talkRoom, talkRoom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void getComments() throws Exception {
.commentLikeCount(0L)
.commentImages(List.of("이미지 URL"))
.registeredDateTime(LocalDateTime.now())
.creatorId(1L)
.build();

PageResponse<CommentFindAllResponse> response = PageResponse.<CommentFindAllResponse>builder()
Expand Down Expand Up @@ -164,6 +165,8 @@ void getComments() throws Exception {
fieldWithPath("data.queryResponse[].registeredDateTime").type(
JsonFieldType.ARRAY)
.description("의견 생성 시간"),
fieldWithPath("data.queryResponse[].creatorId").type(JsonFieldType.NUMBER)
.description("작성자 ID"),
fieldWithPath("data.totalCount").type(JsonFieldType.NUMBER)
.description("의견 총 개수"),
fieldWithPath("data.size").type(JsonFieldType.NUMBER)
Expand Down

0 comments on commit 925c878

Please sign in to comment.