Skip to content

Commit

Permalink
feat : post와 comment 응답에 user id를 포함하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kshired committed Dec 17, 2023
1 parent 2837908 commit a753fd6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ package io.csbroker.apiserver.controller.v1.post.response

import io.csbroker.apiserver.model.Comment
import java.time.LocalDateTime
import java.util.UUID

data class CommentResponseDto(
val id: Long,
val content: String,
val username: String,
val userId: UUID,
val likeCount: Long,
val isLiked: Boolean,
val createdAt: LocalDateTime,
) {
constructor(comment: Comment, likeCount: Long, isLiked: Boolean) : this(
id = comment.id,
content = comment.content,
userId = comment.user.id!!,
username = comment.user.username,
likeCount = likeCount,
isLiked = isLiked,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package io.csbroker.apiserver.controller.v1.post.response

import io.csbroker.apiserver.model.Post
import java.util.UUID

data class PostResponseDto(
val id: Long,
val content: String,
val username: String,
val userId: UUID,
val likeCount: Long,
val isLiked: Boolean,
val comments: List<CommentResponseDto>,
) {
constructor(post: Post, likeCount: Long, isLiked: Boolean, comments: List<CommentResponseDto>) : this(
id = post.id,
content = post.content,
userId = post.user.id!!,
username = post.user.username,
likeCount = likeCount,
isLiked = isLiked,
comments = comments,
comments = comments.sortedBy { it.createdAt },
)
}

0 comments on commit a753fd6

Please sign in to comment.