From fb514e661e644bc40dba3d2413a64ff5e86bf6be Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期三, 11 六月 2025 11:02:29 +0800
Subject: [PATCH] add: 点赞、收藏功能补充
---
src/main/java/com/mzl/flower/service/film/impl/CommentServiceImpl.java | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/mzl/flower/service/film/impl/CommentServiceImpl.java b/src/main/java/com/mzl/flower/service/film/impl/CommentServiceImpl.java
index e854bb9..ecc66c4 100644
--- a/src/main/java/com/mzl/flower/service/film/impl/CommentServiceImpl.java
+++ b/src/main/java/com/mzl/flower/service/film/impl/CommentServiceImpl.java
@@ -164,19 +164,26 @@
* @return
*/
@Override
- public Boolean create(CommentDTO commentDTO) {
+ public CommentDTO create(CommentDTO commentDTO) {
if (StringUtils.isEmpty(commentDTO.getContent())) {
throw new ValidationException("评论内容不能为空");
}
//todo 评论内风险校验,评论内容可以是图片资源,考虑增加一个contextType字段用来区分资源类型
CommentPo commentPo = new CommentPo();
BeanUtils.copyProperties(commentDTO, commentPo);
+ if(StringUtils.isEmpty(commentDTO.getParentId())|| commentDTO.getParentId()<=0){
+ commentPo.setParentId(0);
+ }
commentPo.setState(true);
commentPo.create(SecurityUtils.getUserId());
if (commentPoMapper.insert(commentPo) <= 0) {
- throw new ValidationException("添加评论失败");
+ CommentDTO commentDTO1 = new CommentDTO();
+ return commentDTO1;
+// throw new ValidationException("添加评论失败");
}
- return true;
+ BeanUtils.copyProperties(commentPo, commentDTO);
+ commentDTO.setId(commentPo.getId().intValue());
+ return commentDTO;
}
/**
--
Gitblit v1.9.3