From d9705437b63e87d3c633f50b74ce836b8e159cfb Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 03:31:05 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[refactor]=20soft=20delete=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=EB=AC=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kusitms/samsion/domain/comment/domain/entity/Comment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/kusitms/samsion/domain/comment/domain/entity/Comment.java b/src/main/java/com/kusitms/samsion/domain/comment/domain/entity/Comment.java index 6e79c7b..eef10af 100644 --- a/src/main/java/com/kusitms/samsion/domain/comment/domain/entity/Comment.java +++ b/src/main/java/com/kusitms/samsion/domain/comment/domain/entity/Comment.java @@ -15,7 +15,7 @@ @Getter @Entity @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) -@SQLDelete(sql = "UPDATE comment SET deleted = true WHERE id = ?") +@SQLDelete(sql = "UPDATE comment SET deleted = true WHERE comment_id = ?") public class Comment extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From 1dac534cdf4fdf8b7b3ff46cae582a5ea442264a Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 04:06:44 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[refactor]=20=EB=8C=93=EA=B8=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20@PathVariabl?= =?UTF-8?q?e=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../samsion/domain/comment/presentation/CommentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 72ac0b9..93034f3 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") @DeleteMapping("/{albumId}/comment/{commentId}") - public void delete(@PathVariable Long commentId){ + public void delete(@PathVariable Long albumId,@PathVariable Long commentId){ commentDeleteUseCase.deleteComment(commentId); } From dc9a645ab9c2c9ce55d4bcf55e4f4f78b3d902c6 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 04:37:58 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[refactor]=20=EB=8C=93=EA=B8=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20@Transactional=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/application/service/CommentUpdateUseCase.java | 4 ++++ 1 file changed, 4 insertions(+) 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); From 086746ba6acc369c908d84c6d09d004b8cf17fd5 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 04:40:50 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[refactor]=20CommentInfoResponse=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=EC=97=AC=EB=B6=80=20=EA=B0=92=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/application/dto/response/CommentInfoResponse.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; } } From c18d7adffc3717754ecbadfecbb44c9a8b30ba67 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 04:46:58 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[refactor]=20=EB=8C=93=EA=B8=80=20API=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/static/docs/Comment-API.html | 38 +++++++++++++++++-- src/main/resources/static/docs/index.html | 38 +++++++++++++++++-- .../presentation/CommentControllerTest.java | 12 +++++- 3 files changed, 78 insertions(+), 10 deletions(-) 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("페이지 사이즈"), From ebfe5c38fdb31059e25663cb8610d8171a2fac49 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Wed, 24 May 2023 05:03:12 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[refactor]=20mapper=EC=97=90=20deleted=20?= =?UTF-8?q?=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../samsion/domain/comment/application/mapper/CommentMapper.java | 1 + 1 file changed, 1 insertion(+) 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(); }