-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ♻️ 코멘트 도메인 분리 (#263) * ✨ 코멘트 공개/비공개, 유실물 ID 컬럼 추가로 인한 엔티티 변경 (#263) * ♻️ 게시글 타입 분기 및 공개/비공개 여부 추가로 인한 코멘트 생성 로직 변경 (#263) * ♻️ 코멘트 생성 API 스펙 변경으로 인한 Controller, REST Docs 변경 (#263) * ♻️ 코멘트 컬럼 및 테이블명 변경 (#263) * ♻️ 코멘트 비공개/공개 여부 isPrivate Boolean 필드 추가 (#263) * ♻️ 코멘트 조회 및 생성 API 계층 구조 변경 (#263) * ✨ 자식 코멘트 생성 시, 비공개 여부 필드 요청 시 예외처리 (#263) * ✨ 부모 댓글 존재 시, 부모 visibility 따라가도록 설정 (#263)
- Loading branch information
Showing
62 changed files
with
1,224 additions
and
795 deletions.
There are no files selected for viewing
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,27 @@ | ||
=== /comments | ||
|
||
==== 코멘트 수정 | ||
|
||
.Request | ||
include::{snippets}/update-comment/http-request.adoc[] | ||
.Request Headers | ||
include::{snippets}/update-comment/request-headers.adoc[] | ||
.Path Parameters | ||
include::{snippets}/update-comment/path-parameters.adoc[] | ||
.Response | ||
include::{snippets}/update-comment/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/update-comment/response-fields.adoc[] | ||
|
||
==== 코멘트 삭제 | ||
|
||
.Request | ||
include::{snippets}/delete-comment/http-request.adoc[] | ||
.Request Headers | ||
include::{snippets}/delete-comment/request-headers.adoc[] | ||
.Path Parameters | ||
include::{snippets}/delete-comment/path-parameters.adoc[] | ||
.Response | ||
include::{snippets}/delete-comment/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/delete-comment/response-fields.adoc[] |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
application/src/docs/asciidoc/community/posts-comments.adoc
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,26 @@ | ||
==== 게시글 코멘트 조회 | ||
|
||
.Request | ||
include::{snippets}/get-community-post-comments/http-request.adoc[] | ||
.Path Parameters | ||
include::{snippets}/get-community-post-comments/path-parameters.adoc[] | ||
.Response | ||
include::{snippets}/get-community-post-comments/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/get-community-post-comments/response-fields.adoc[] | ||
|
||
==== 게시글 코멘트 작성 | ||
|
||
.Request | ||
include::{snippets}/create-community-post-comment/http-request.adoc[] | ||
.Request Headers | ||
include::{snippets}/create-community-post-comment/request-headers.adoc[] | ||
.Path Parameters | ||
include::{snippets}/create-community-post-comment/path-parameters.adoc[] | ||
.Request Fields | ||
include::{snippets}/create-community-post-comment/request-fields.adoc[] | ||
.Response | ||
include::{snippets}/create-community-post-comment/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/create-community-post-comment/response-fields.adoc[] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
==== 유실물 코멘트 조회 | ||
|
||
.Request | ||
include::{snippets}/get-lost-post-comments/http-request.adoc[] | ||
.Path Parameters | ||
include::{snippets}/get-lost-post-comments/path-parameters.adoc[] | ||
.Response | ||
include::{snippets}/get-lost-post-comments/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/get-lost-post-comments/response-fields.adoc[] | ||
|
||
==== 유실물 코멘트 작성 | ||
|
||
.Request | ||
include::{snippets}/create-lost-post-comment/http-request.adoc[] | ||
.Request Headers | ||
include::{snippets}/create-lost-post-comment/request-headers.adoc[] | ||
.Path Parameters | ||
include::{snippets}/create-lost-post-comment/path-parameters.adoc[] | ||
.Request Fields | ||
include::{snippets}/create-lost-post-comment/request-fields.adoc[] | ||
.Response | ||
include::{snippets}/create-lost-post-comment/http-response.adoc[] | ||
.Response Fields | ||
include::{snippets}/create-lost-post-comment/response-fields.adoc[] | ||
|
27 changes: 27 additions & 0 deletions
27
.../main/kotlin/backend/team/ahachul_backend/api/comment/adapter/web/in/CommentController.kt
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,27 @@ | ||
package backend.team.ahachul_backend.api.comment.adapter.web.`in` | ||
|
||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.DeleteCommentDto | ||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.UpdateCommentDto | ||
import backend.team.ahachul_backend.api.comment.application.command.DeleteCommentCommand | ||
import backend.team.ahachul_backend.api.comment.application.port.`in`.CommentUseCase | ||
import backend.team.ahachul_backend.common.annotation.Authentication | ||
import backend.team.ahachul_backend.common.response.CommonResponse | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
class CommentController( | ||
private val commentUseCase: CommentUseCase | ||
) { | ||
|
||
@Authentication | ||
@PatchMapping("/v1/comments/{commentId}") | ||
fun updateComment(@PathVariable commentId: Long, @RequestBody request: UpdateCommentDto.Request): CommonResponse<UpdateCommentDto.Response> { | ||
return CommonResponse.success(commentUseCase.updateComment(request.toCommand(commentId))) | ||
} | ||
|
||
@Authentication | ||
@DeleteMapping("/v1/comments/{commentId}") | ||
fun deleteComment(@PathVariable commentId: Long): CommonResponse<DeleteCommentDto.Response> { | ||
return CommonResponse.success(commentUseCase.deleteComment(DeleteCommentCommand(commentId))) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...in/kotlin/backend/team/ahachul_backend/api/comment/adapter/web/in/dto/CreateCommentDto.kt
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,56 @@ | ||
package backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto | ||
|
||
import backend.team.ahachul_backend.api.comment.application.command.CreateCommentCommand | ||
import backend.team.ahachul_backend.api.comment.domain.entity.CommentEntity import backend.team.ahachul_backend.api.comment.domain.model.CommentVisibility | ||
import backend.team.ahachul_backend.api.comment.domain.model.PostType | ||
import backend.team.ahachul_backend.common.exception.CommonException | ||
import backend.team.ahachul_backend.common.response.ResponseCode | ||
|
||
class CreateCommentDto { | ||
|
||
data class Request( | ||
val upperCommentId: Long?, | ||
val content: String, | ||
val isPrivate: Boolean? | ||
) { | ||
init { | ||
validateChildComment() | ||
} | ||
|
||
fun toCommand(postId: Long, postType: PostType): CreateCommentCommand { | ||
return CreateCommentCommand( | ||
postId = postId, | ||
postType = postType, | ||
upperCommentId = upperCommentId, | ||
content = content, | ||
visibility = CommentVisibility.from(isPrivate) | ||
) | ||
} | ||
|
||
private fun validateChildComment() { | ||
if (isInvalidChildComment()) { | ||
throw CommonException(ResponseCode.BAD_REQUEST) | ||
} | ||
} | ||
|
||
private fun isInvalidChildComment(): Boolean { | ||
return upperCommentId != null && isPrivate != null | ||
} | ||
} | ||
|
||
data class Response( | ||
val id: Long, | ||
val upperCommentId: Long?, | ||
val content: String, | ||
) { | ||
companion object { | ||
fun from(entity: CommentEntity): Response { | ||
return Response( | ||
id = entity.id, | ||
upperCommentId = entity.upperComment?.id, | ||
content = entity.content | ||
) | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...in/kotlin/backend/team/ahachul_backend/api/comment/adapter/web/in/dto/DeleteCommentDto.kt
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,8 @@ | ||
package backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto | ||
|
||
class DeleteCommentDto { | ||
|
||
data class Response( | ||
val id: Long, | ||
) | ||
} |
26 changes: 26 additions & 0 deletions
26
...main/kotlin/backend/team/ahachul_backend/api/comment/adapter/web/in/dto/GetCommentsDto.kt
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,26 @@ | ||
package backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto | ||
|
||
import backend.team.ahachul_backend.api.comment.domain.model.CommentType | ||
import java.time.LocalDateTime | ||
|
||
class GetCommentsDto { | ||
|
||
data class Response( | ||
val comments: List<CommentList> | ||
) | ||
|
||
data class CommentList( | ||
val parentComment: Comment, | ||
val childComments: List<Comment> | ||
) | ||
|
||
data class Comment( | ||
val id: Long, | ||
val upperCommentId: Long?, | ||
val content: String, | ||
val status: CommentType, | ||
val createdAt: LocalDateTime, | ||
val createdBy: String, | ||
val writer: String, | ||
) | ||
} |
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
21 changes: 21 additions & 0 deletions
21
...ain/kotlin/backend/team/ahachul_backend/api/comment/application/port/in/CommentUseCase.kt
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,21 @@ | ||
package backend.team.ahachul_backend.api.comment.application.port.`in` | ||
|
||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.CreateCommentDto | ||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.DeleteCommentDto | ||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.GetCommentsDto | ||
import backend.team.ahachul_backend.api.comment.adapter.web.`in`.dto.UpdateCommentDto | ||
import backend.team.ahachul_backend.api.comment.application.command.CreateCommentCommand | ||
import backend.team.ahachul_backend.api.comment.application.command.DeleteCommentCommand | ||
import backend.team.ahachul_backend.api.comment.application.command.GetCommentsCommand | ||
import backend.team.ahachul_backend.api.comment.application.command.UpdateCommentCommand | ||
|
||
interface CommentUseCase { | ||
|
||
fun getComments(command: GetCommentsCommand): GetCommentsDto.Response | ||
|
||
fun createComment(command: CreateCommentCommand): CreateCommentDto.Response | ||
|
||
fun updateComment(command: UpdateCommentCommand): UpdateCommentDto.Response | ||
|
||
fun deleteComment(command: DeleteCommentCommand): DeleteCommentDto.Response | ||
} |
Oops, something went wrong.