diff --git a/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/api/KeyValueFeignApi.java b/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/api/KeyValueFeignApi.java index 9560afa..5327865 100644 --- a/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/api/KeyValueFeignApi.java +++ b/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/api/KeyValueFeignApi.java @@ -31,4 +31,6 @@ public interface KeyValueFeignApi { @PostMapping(value = PREFIX + "/comment/content/batchFind") Response> batchFindCommentContent(@RequestBody BatchFindCommentContentReqDTO batchFindCommentContentReqDTO); + @PostMapping(value = PREFIX + "/comment/content/delete") + Response deleteCommentContent(@RequestBody DeleteCommentContentReqDTO deleteCommentContentReqDTO); } \ No newline at end of file diff --git a/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/dto/req/DeleteCommentContentReqDTO.java b/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/dto/req/DeleteCommentContentReqDTO.java new file mode 100644 index 0000000..dbd2f8a --- /dev/null +++ b/han-note-kv/han-note-kv-api/src/main/java/com/hanserwei/hannote/kv/dto/req/DeleteCommentContentReqDTO.java @@ -0,0 +1,25 @@ +package com.hanserwei.hannote.kv.dto.req; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class DeleteCommentContentReqDTO { + + @NotNull(message = "笔记 ID 不能为空") + private Long noteId; + + @NotBlank(message = "发布年月不能为空") + private String yearMonth; + + @NotBlank(message = "评论正文 ID 不能为空") + private String contentId; + +} \ No newline at end of file diff --git a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/controller/CommentContentController.java b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/controller/CommentContentController.java index d91e3d0..d46ed04 100644 --- a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/controller/CommentContentController.java +++ b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/controller/CommentContentController.java @@ -5,6 +5,7 @@ import com.hanserwei.framework.common.response.Response; import com.hanserwei.hannote.kv.biz.service.CommentContentService; import com.hanserwei.hannote.kv.dto.req.BatchAddCommentContentReqDTO; import com.hanserwei.hannote.kv.dto.req.BatchFindCommentContentReqDTO; +import com.hanserwei.hannote.kv.dto.req.DeleteCommentContentReqDTO; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; @@ -33,4 +34,10 @@ public class CommentContentController { return commentContentService.batchFindCommentContent(batchFindCommentContentReqDTO); } + @PostMapping(value = "/comment/content/delete") + @ApiOperationLog(description = "删除评论内容") + public Response deleteCommentContent(@Validated @RequestBody DeleteCommentContentReqDTO deleteCommentContentReqDTO) { + return commentContentService.deleteCommentContent(deleteCommentContentReqDTO); + } + } diff --git a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/domain/repository/CommentContentRepository.java b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/domain/repository/CommentContentRepository.java index c37ef1a..e87c8b8 100644 --- a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/domain/repository/CommentContentRepository.java +++ b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/domain/repository/CommentContentRepository.java @@ -20,4 +20,13 @@ public interface CommentContentRepository extends CassandraRepository findByPrimaryKeyNoteIdAndPrimaryKeyYearMonthInAndPrimaryKeyContentIdIn( Long noteId, List yearMonths, List contentIds ); + + /** + * 删除评论正文 + * + * @param noteId 笔记ID + * @param yearMonth 年月 + * @param contentId 评论 ID + */ + void deleteByPrimaryKeyNoteIdAndPrimaryKeyYearMonthAndPrimaryKeyContentId(Long noteId, String yearMonth, UUID contentId); } \ No newline at end of file diff --git a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/CommentContentService.java b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/CommentContentService.java index 7696c00..4780e20 100644 --- a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/CommentContentService.java +++ b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/CommentContentService.java @@ -3,6 +3,7 @@ package com.hanserwei.hannote.kv.biz.service; import com.hanserwei.framework.common.response.Response; import com.hanserwei.hannote.kv.dto.req.BatchAddCommentContentReqDTO; import com.hanserwei.hannote.kv.dto.req.BatchFindCommentContentReqDTO; +import com.hanserwei.hannote.kv.dto.req.DeleteCommentContentReqDTO; public interface CommentContentService { @@ -21,4 +22,13 @@ public interface CommentContentService { * @return 批量查询结果 */ Response batchFindCommentContent(BatchFindCommentContentReqDTO batchFindCommentContentReqDTO); + + /** + * 删除评论内容 + * + * @param deleteCommentContentReqDTO 删除评论内容请求参数 + * @return 删除结果 + */ + Response deleteCommentContent(DeleteCommentContentReqDTO deleteCommentContentReqDTO); + } diff --git a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/impl/CommentContentServiceImpl.java b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/impl/CommentContentServiceImpl.java index 9c1790c..37d3436 100644 --- a/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/impl/CommentContentServiceImpl.java +++ b/han-note-kv/han-note-kv-biz/src/main/java/com/hanserwei/hannote/kv/biz/service/impl/CommentContentServiceImpl.java @@ -7,10 +7,7 @@ import com.hanserwei.hannote.kv.biz.domain.dataobject.CommentContentDO; import com.hanserwei.hannote.kv.biz.domain.dataobject.CommentContentPrimaryKey; import com.hanserwei.hannote.kv.biz.domain.repository.CommentContentRepository; import com.hanserwei.hannote.kv.biz.service.CommentContentService; -import com.hanserwei.hannote.kv.dto.req.BatchAddCommentContentReqDTO; -import com.hanserwei.hannote.kv.dto.req.BatchFindCommentContentReqDTO; -import com.hanserwei.hannote.kv.dto.req.CommentContentReqDTO; -import com.hanserwei.hannote.kv.dto.req.FindCommentContentReqDTO; +import com.hanserwei.hannote.kv.dto.req.*; import com.hanserwei.hannote.kv.dto.resp.FindCommentContentRspDTO; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotBlank; @@ -91,4 +88,16 @@ public class CommentContentServiceImpl implements CommentContentService { return Response.success(findCommentContentRspDTOS); } + + @Override + public Response deleteCommentContent(DeleteCommentContentReqDTO deleteCommentContentReqDTO) { + Long noteId = deleteCommentContentReqDTO.getNoteId(); + String yearMonth = deleteCommentContentReqDTO.getYearMonth(); + String contentId = deleteCommentContentReqDTO.getContentId(); + + // 删除评论正文 + commentContentRepository.deleteByPrimaryKeyNoteIdAndPrimaryKeyYearMonthAndPrimaryKeyContentId(noteId, yearMonth, UUID.fromString(contentId)); + + return Response.success(); + } } diff --git a/http-client/gateApi.http b/http-client/gateApi.http index 94ee0ba..4d2b3bd 100644 --- a/http-client/gateApi.http +++ b/http-client/gateApi.http @@ -384,3 +384,13 @@ Authorization: Bearer {{token}} { "commentId": 8001 } + +### 删除评论 +POST http://localhost:8084/kv/comment/content/delete +Content-Type: application/json + +{ + "noteId": 1862481582414102549, + "yearMonth": "2025-11", + "contentId": "0fa4376f-a098-4fee-821b-f5b7e627a72c" +}