feat(note): 实现笔记发布功能并优化数据模型
- 新增笔记发布接口,支持图文和视频类型 - 引入分布式ID生成器和KV存储服务 - 修改笔记、频道、话题等实体类使用LocalDateTime - 添加频道-话题关联表及相应服务实现 - 更新数据库表结构,增加笔记内容UUID字段 - 完善笔记发布时的内容校验和异常处理 - 配置网关路由支持新的笔记服务路径 - 优化MyBatis Mapper扫描和Feign客户端配置
This commit is contained in:
@@ -3,6 +3,7 @@ package com.hanserwei.hannote.kv.api;
|
||||
import com.hanserwei.framework.common.response.Response;
|
||||
import com.hanserwei.hannote.kv.constant.ApiConstants;
|
||||
import com.hanserwei.hannote.kv.dto.req.AddNoteContentReqDTO;
|
||||
import com.hanserwei.hannote.kv.dto.req.DeleteNoteContentReqDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -19,6 +20,6 @@ public interface KeyValueFeignApi {
|
||||
Response<?> findNoteContent(@RequestBody AddNoteContentReqDTO addNoteContentReqDTO);
|
||||
|
||||
@PostMapping(value = PREFIX + "/note/content/delete")
|
||||
Response<?> deleteNoteContent(@RequestBody AddNoteContentReqDTO addNoteContentReqDTO);
|
||||
Response<?> deleteNoteContent(@RequestBody DeleteNoteContentReqDTO deleteNoteContentReqDTO);
|
||||
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
public class AddNoteContentReqDTO {
|
||||
|
||||
@NotNull(message = "笔记 ID 不能为空")
|
||||
private Long noteId;
|
||||
@NotNull(message = "笔记内容 UUID 不能为空")
|
||||
private String uuid;
|
||||
|
||||
@NotBlank(message = "笔记内容不能为空")
|
||||
private String content;
|
||||
|
||||
@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
public class DeleteNoteContentReqDTO {
|
||||
|
||||
@NotBlank(message = "笔记 ID 不能为空")
|
||||
private String noteId;
|
||||
@NotBlank(message = "笔记 UUID 不能为空")
|
||||
private String uuid;
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
public class FindNoteContentReqDTO {
|
||||
|
||||
@NotBlank(message = "笔记 ID 不能为空")
|
||||
private String noteId;
|
||||
@NotBlank(message = "笔记 UUID 不能为空")
|
||||
private String uuid;
|
||||
|
||||
}
|
||||
@@ -27,12 +27,12 @@ public class NoteContentServiceImpl implements NoteContentService {
|
||||
@Override
|
||||
public Response<?> addNoteContent(AddNoteContentReqDTO addNoteContentReqDTO) {
|
||||
// 笔记ID
|
||||
Long noteId = addNoteContentReqDTO.getNoteId();
|
||||
String noteId = addNoteContentReqDTO.getUuid();
|
||||
// 笔记内容
|
||||
String content = addNoteContentReqDTO.getContent();
|
||||
|
||||
NoteContentDO noteContent = NoteContentDO.builder()
|
||||
.id(UUID.randomUUID())
|
||||
.id(UUID.fromString(noteId))
|
||||
.content(content)
|
||||
.build();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class NoteContentServiceImpl implements NoteContentService {
|
||||
@Override
|
||||
public Response<FindNoteContentRspDTO> findNoteContent(FindNoteContentReqDTO findNoteContentReqDTO) {
|
||||
// 笔记ID
|
||||
String noteId = findNoteContentReqDTO.getNoteId();
|
||||
String noteId = findNoteContentReqDTO.getUuid();
|
||||
Optional<NoteContentDO> optional = noteContentRepository.findById(UUID.fromString(noteId));
|
||||
if (optional.isEmpty()){
|
||||
throw new ApiException(ResponseCodeEnum.NOTE_CONTENT_NOT_FOUND);
|
||||
@@ -60,7 +60,7 @@ public class NoteContentServiceImpl implements NoteContentService {
|
||||
|
||||
@Override
|
||||
public Response<?> deleteNoteContent(DeleteNoteContentReqDTO deleteNoteContentReqDTO) {
|
||||
String noteId = deleteNoteContentReqDTO.getNoteId();
|
||||
String noteId = deleteNoteContentReqDTO.getUuid();
|
||||
noteContentRepository.deleteById(UUID.fromString(noteId));
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user