feat(kv): 新增删除评论内容功能
- 在 CommentContentController 中新增删除评论内容的接口 - 定义 DeleteCommentContentReqDTO 用于接收删除请求参数 - 在 CommentContentRepository 中新增删除评论正文的方法 - 在 CommentContentService 及其实现类中新增删除评论内容的业务逻辑 - 在 KeyValueFeignApi 中新增删除评论内容的 Feign 接口 - 在 gateApi.http 中添加删除评论内容的测试用例
This commit is contained in:
@@ -31,4 +31,6 @@ public interface KeyValueFeignApi {
|
||||
@PostMapping(value = PREFIX + "/comment/content/batchFind")
|
||||
Response<List<FindCommentContentRspDTO>> batchFindCommentContent(@RequestBody BatchFindCommentContentReqDTO batchFindCommentContentReqDTO);
|
||||
|
||||
@PostMapping(value = PREFIX + "/comment/content/delete")
|
||||
Response<?> deleteCommentContent(@RequestBody DeleteCommentContentReqDTO deleteCommentContentReqDTO);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,13 @@ public interface CommentContentRepository extends CassandraRepository<CommentCon
|
||||
List<CommentContentDO> findByPrimaryKeyNoteIdAndPrimaryKeyYearMonthInAndPrimaryKeyContentIdIn(
|
||||
Long noteId, List<String> yearMonths, List<UUID> contentIds
|
||||
);
|
||||
|
||||
/**
|
||||
* 删除评论正文
|
||||
*
|
||||
* @param noteId 笔记ID
|
||||
* @param yearMonth 年月
|
||||
* @param contentId 评论 ID
|
||||
*/
|
||||
void deleteByPrimaryKeyNoteIdAndPrimaryKeyYearMonthAndPrimaryKeyContentId(Long noteId, String yearMonth, UUID contentId);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user