diff --git a/src/main/java/com/kusitms/samsion/domain/comment/application/dto/response/CommentInfoResponse.java b/src/main/java/com/kusitms/samsion/domain/comment/application/dto/response/CommentInfoResponse.java index 0b26d79..1f627e9 100644 --- a/src/main/java/com/kusitms/samsion/domain/comment/application/dto/response/CommentInfoResponse.java +++ b/src/main/java/com/kusitms/samsion/domain/comment/application/dto/response/CommentInfoResponse.java @@ -17,15 +17,17 @@ public class CommentInfoResponse { private final String description; private final String writer; private final String writerProfileImageUrl; + private final boolean deleted; private final boolean changeable; private List child; @Builder - public CommentInfoResponse(Long commentId, String description, String writer, String writerProfileImageUrl, boolean changeable) { + public CommentInfoResponse(Long commentId, String description, String writer, String writerProfileImageUrl, boolean deleted, boolean changeable) { this.commentId = commentId; this.description = description; this.writer = writer; this.writerProfileImageUrl = writerProfileImageUrl; + this.deleted = deleted; this.changeable = changeable; } } diff --git a/src/main/java/com/kusitms/samsion/domain/comment/application/mapper/CommentMapper.java b/src/main/java/com/kusitms/samsion/domain/comment/application/mapper/CommentMapper.java index 737ddb1..176a5a5 100644 --- a/src/main/java/com/kusitms/samsion/domain/comment/application/mapper/CommentMapper.java +++ b/src/main/java/com/kusitms/samsion/domain/comment/application/mapper/CommentMapper.java @@ -38,6 +38,7 @@ public static CommentInfoResponse mapToCommentInfoResponse(Comment comment, User .description(comment.getDescription()) .writer(writer.getNickname()) .writerProfileImageUrl(writer.getMypet().getPetImageUrl()) + .deleted(comment.isDeleted()) .changeable(Objects.equals(writer.getId(), accessUser.getId())) .build(); } diff --git a/src/main/java/com/kusitms/samsion/domain/comment/application/service/CommentUpdateUseCase.java b/src/main/java/com/kusitms/samsion/domain/comment/application/service/CommentUpdateUseCase.java index 23ca903..b55bc4a 100644 --- a/src/main/java/com/kusitms/samsion/domain/comment/application/service/CommentUpdateUseCase.java +++ b/src/main/java/com/kusitms/samsion/domain/comment/application/service/CommentUpdateUseCase.java @@ -7,16 +7,20 @@ import com.kusitms.samsion.domain.comment.application.mapper.CommentMapper; import com.kusitms.samsion.domain.comment.domain.entity.Comment; import com.kusitms.samsion.domain.comment.domain.service.CommentQueryService; +import com.kusitms.samsion.domain.comment.domain.service.CommentSaveService; import com.kusitms.samsion.domain.comment.domain.service.CommentValidAccessService; import com.kusitms.samsion.domain.user.domain.entity.User; import lombok.RequiredArgsConstructor; +import javax.transaction.Transactional; + @UseCase @RequiredArgsConstructor public class CommentUpdateUseCase { private final UserUtils userUtils; private final CommentQueryService commentQueryService; private final CommentValidAccessService commentValidAccessService; + @Transactional public CommentInfoResponse updateComment(Long commentId, CommentUpdateRequest commentUpdateRequest) { final User user = userUtils.getUser(); final Comment comment = commentQueryService.getCommentById(commentId); diff --git a/src/main/java/com/kusitms/samsion/domain/comment/presentation/CommentController.java b/src/main/java/com/kusitms/samsion/domain/comment/presentation/CommentController.java index 8abbfb4..2175787 100644 --- a/src/main/java/com/kusitms/samsion/domain/comment/presentation/CommentController.java +++ b/src/main/java/com/kusitms/samsion/domain/comment/presentation/CommentController.java @@ -45,7 +45,7 @@ public CommentInfoResponse update(@PathVariable Long commentId, @RequestBody Com @CacheEvict(value = CachingStoreConst.COMMENT_COUNT_CACHE_NAME, key = "#albumId",condition="#albumId!=null") @DeleteMapping("/{albumId}/comment/{commentId}") - public void delete(@PathVariable Long commentId){ + public void delete(@PathVariable Long albumId,@PathVariable Long commentId){ commentDeleteUseCase.deleteComment(commentId); } diff --git a/src/main/resources/static/docs/Comment-API.html b/src/main/resources/static/docs/Comment-API.html index 5a52409..c3833cf 100644 --- a/src/main/resources/static/docs/Comment-API.html +++ b/src/main/resources/static/docs/Comment-API.html @@ -534,13 +534,14 @@

HTTP response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 159
+Content-Length: 181
 
 {
   "commentId" : 1,
   "description" : "testCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }
@@ -583,6 +584,11 @@

Response fields

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -687,13 +693,14 @@

HTTP response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 164
+Content-Length: 186
 
 {
   "commentId" : 2,
   "description" : "testChildCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }
@@ -736,6 +743,11 @@

Response fields

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -840,13 +852,14 @@

HTTP response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 165
+Content-Length: 187
 
 {
   "commentId" : 1,
   "description" : "testUpdateCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }
@@ -889,6 +902,11 @@

Response fields

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -1053,7 +1071,7 @@

HTTP response

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 459
+Content-Length: 509
 
 {
   "content" : [ {
@@ -1061,12 +1079,14 @@ 

HTTP response

"description" : "testCommentDescription", "writer" : "test", "writerProfileImageUrl" : "testImageUrl", + "deleted" : false, "changeable" : false, "child" : [ { "commentId" : 2, "description" : "testChildCommentDescription", "writer" : "test", "writerProfileImageUrl" : "testImageUrl", + "deleted" : false, "changeable" : false } ] } ], @@ -1114,6 +1134,11 @@

Response fields

작성자 프로필 사진

+

content[].deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

content[].changeable

Boolean

변경 가능 여부

@@ -1139,6 +1164,11 @@

Response fields

작성자 프로필 사진

+

content[].child[].deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

content[].child[].changeable

Boolean

변경 가능 여부

diff --git a/src/main/resources/static/docs/index.html b/src/main/resources/static/docs/index.html index d06ba0a..7937d41 100644 --- a/src/main/resources/static/docs/index.html +++ b/src/main/resources/static/docs/index.html @@ -1725,13 +1725,14 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 159
+Content-Length: 181
 
 {
   "commentId" : 1,
   "description" : "testCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }

@@ -1774,6 +1775,11 @@

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -1878,13 +1884,14 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 164
+Content-Length: 186
 
 {
   "commentId" : 2,
   "description" : "testChildCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }
@@ -1927,6 +1934,11 @@

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -2031,13 +2043,14 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 165
+Content-Length: 187
 
 {
   "commentId" : 1,
   "description" : "testUpdateCommentDescription",
   "writer" : "test",
   "writerProfileImageUrl" : "testImageUrl",
+  "deleted" : false,
   "changeable" : true
 }
@@ -2080,6 +2093,11 @@

작성자 프로필 사진

+

deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

changeable

Boolean

변경 가능 여부

@@ -2244,7 +2262,7 @@

HTTP/1.1 200 OK
 Content-Type: application/json;charset=UTF-8
-Content-Length: 459
+Content-Length: 509
 
 {
   "content" : [ {
@@ -2252,12 +2270,14 @@ 

작성자 프로필 사진

+

content[].deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

content[].changeable

Boolean

변경 가능 여부

@@ -2330,6 +2355,11 @@

작성자 프로필 사진

+

content[].child[].deleted

+

Boolean

+

삭제 여부. 삭제 되었으면 true, 아니면 false

+ +

content[].child[].changeable

Boolean

변경 가능 여부

diff --git a/src/test/java/com/kusitms/samsion/domain/comment/presentation/CommentControllerTest.java b/src/test/java/com/kusitms/samsion/domain/comment/presentation/CommentControllerTest.java index cf57a51..25b08b3 100644 --- a/src/test/java/com/kusitms/samsion/domain/comment/presentation/CommentControllerTest.java +++ b/src/test/java/com/kusitms/samsion/domain/comment/presentation/CommentControllerTest.java @@ -60,6 +60,7 @@ public class CommentControllerTest extends CommonRestDocs{ .description(TestConst.TEST_COMMENT_DESCRIPTION) .writer(TestConst.TEST_NICKNAME) .writerProfileImageUrl(TestConst.TEST_PET_IMAGE_URL) + .deleted(false) .changeable(true) .build(); given(commentCreateUseCase.createComment(any(), any())).willReturn(commentInfoResponse); @@ -90,6 +91,7 @@ public class CommentControllerTest extends CommonRestDocs{ fieldWithPath("description").description("댓글 내용"), fieldWithPath("writer").description("댓글 작성자"), fieldWithPath("writerProfileImageUrl").description("작성자 프로필 사진"), + fieldWithPath("deleted").description("삭제 여부. 삭제 되었으면 true, 아니면 false"), fieldWithPath("changeable").description("변경 가능 여부") ) ) @@ -105,6 +107,7 @@ public class CommentControllerTest extends CommonRestDocs{ .description(TestConst.TEST_CHILD_COMMENT_DESCRIPTION) .writer(TestConst.TEST_NICKNAME) .writerProfileImageUrl(TestConst.TEST_PET_IMAGE_URL) + .deleted(false) .changeable(true) .build(); given(commentCreateUseCase.createReComment(any(), any(), any())).willReturn(commentInfoResponse); @@ -136,6 +139,7 @@ public class CommentControllerTest extends CommonRestDocs{ fieldWithPath("description").description("댓글 내용"), fieldWithPath("writer").description("댓글 작성자"), fieldWithPath("writerProfileImageUrl").description("작성자 프로필 사진"), + fieldWithPath("deleted").description("삭제 여부. 삭제 되었으면 true, 아니면 false"), fieldWithPath("changeable").description("변경 가능 여부") ) ) @@ -152,6 +156,7 @@ public class CommentControllerTest extends CommonRestDocs{ .description(TestConst.TEST_UPDATE_COMMENT_DESCRIPTION) .writer(TestConst.TEST_NICKNAME) .writerProfileImageUrl(TestConst.TEST_PET_IMAGE_URL) + .deleted(false) .changeable(true) .build(); given(commentUpdateUseCase.updateComment(any(), any())).willReturn(commentInfoResponse); @@ -183,6 +188,7 @@ public class CommentControllerTest extends CommonRestDocs{ fieldWithPath("description").description("댓글 내용"), fieldWithPath("writer").description("댓글 작성자"), fieldWithPath("writerProfileImageUrl").description("작성자 프로필 사진"), + fieldWithPath("deleted").description("삭제 여부. 삭제 되었으면 true, 아니면 false"), fieldWithPath("changeable").description("변경 가능 여부") ) ) @@ -219,9 +225,9 @@ public class CommentControllerTest extends CommonRestDocs{ User mockUser = UserTestUtils.getMockUser(); Pageable pageRequest = SliceTestUtils.getMockPageable(); List children = new ArrayList<>(Arrays.asList(new CommentInfoResponse(TestConst.TEST_CHILD_ID, - TestConst.TEST_CHILD_COMMENT_DESCRIPTION, TestConst.TEST_NICKNAME, TestConst.TEST_PET_IMAGE_URL, false))); + TestConst.TEST_CHILD_COMMENT_DESCRIPTION, TestConst.TEST_NICKNAME, TestConst.TEST_PET_IMAGE_URL, false, false))); CommentInfoResponse commentInfoResponse = new CommentInfoResponse(TestConst.TEST_COMMENT_ID,TestConst.TEST_COMMENT_DESCRIPTION, - TestConst.TEST_NICKNAME, TestConst.TEST_PET_IMAGE_URL, false, children); + TestConst.TEST_NICKNAME, TestConst.TEST_PET_IMAGE_URL,false, false, children); SliceResponse mockPageResponse = SliceTestUtils.getMockSliceResponse(commentInfoResponse); given(commentReadUseCase.getCommentList(pageRequest, TestConst.TEST_ALBUM_ID)).willReturn(mockPageResponse); //when @@ -250,11 +256,13 @@ public class CommentControllerTest extends CommonRestDocs{ fieldWithPath("content[].description").description("댓글 내용"), fieldWithPath("content[].writer").description("댓글 작성자"), fieldWithPath("content[].writerProfileImageUrl").description("작성자 프로필 사진"), + fieldWithPath("content[].deleted").description("삭제 여부. 삭제 되었으면 true, 아니면 false"), fieldWithPath("content[].changeable").description("변경 가능 여부"), fieldWithPath("content[].child[].commentId").description("댓글 ID"), fieldWithPath("content[].child[].description").description("댓글 내용"), fieldWithPath("content[].child[].writer").description("댓글 작성자"), fieldWithPath("content[].child[].writerProfileImageUrl").description("작성자 프로필 사진"), + fieldWithPath("content[].child[].deleted").description("삭제 여부. 삭제 되었으면 true, 아니면 false"), fieldWithPath("content[].child[].changeable").description("변경 가능 여부"), fieldWithPath("page").description("현재 페이지"), fieldWithPath("size").description("페이지 사이즈"),