|
@@ -17,11 +17,9 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
-import static com.ruoyi.common.constant.Constants.COMMUNITY_COMMENT_COUNT;
|
|
|
|
-import static com.ruoyi.common.constant.Constants.TWO_MY_LIKE;
|
|
|
|
|
|
+import static com.ruoyi.common.constant.Constants.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 社区资讯评论Service业务层处理
|
|
* 社区资讯评论Service业务层处理
|
|
@@ -145,7 +143,6 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
|
|
int result = 0;
|
|
int result = 0;
|
|
int communityCommentCount = 0;
|
|
int communityCommentCount = 0;
|
|
//查找出所有parent_id = commentId的commentId
|
|
//查找出所有parent_id = commentId的commentId
|
|
- List<Long> commentIdList = new ArrayList<>();
|
|
|
|
if (commentIndex != null && commentIndex.getUserId().equals(SecurityUtils.getUserId())) {
|
|
if (commentIndex != null && commentIndex.getUserId().equals(SecurityUtils.getUserId())) {
|
|
//社区资讯id
|
|
//社区资讯id
|
|
Long communityId = commentIndex.getCommunityId();
|
|
Long communityId = commentIndex.getCommunityId();
|
|
@@ -172,6 +169,20 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
|
|
}
|
|
}
|
|
redisCache.setCacheObject(communityCommentCountKey, communityCommentCount);
|
|
redisCache.setCacheObject(communityCommentCountKey, communityCommentCount);
|
|
}
|
|
}
|
|
|
|
+ //删除社区资讯评论点赞的数量永久key key=two_like_count:{评论id} value = 该评论的点赞数量
|
|
|
|
+ redisCache.deleteObject(TWO_LIKE_COUNT + commentId);
|
|
|
|
+ //社区资讯回复点赞的人员集合的key
|
|
|
|
+ redisCache.deleteObject(TWO_LIKE + commentId);
|
|
|
|
+ //对应用户点赞的回复key=two_my_like:{用户id} value = [评论id]
|
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
|
+ List<Long> commentIdList = redisCache.getCacheList(TWO_MY_LIKE + userId);
|
|
|
|
+ if (commentIdList != null && commentIdList.size() > 0){
|
|
|
|
+ commentIdList.remove(commentId);
|
|
|
|
+ }
|
|
|
|
+ redisCache.deleteObject(TWO_MY_LIKE + userId);
|
|
|
|
+ if (commentIdList != null && commentIdList.size() > 0){
|
|
|
|
+ redisCache.setCacheList(TWO_MY_LIKE + userId,commentIdList);
|
|
|
|
+ }
|
|
/* //删除该资讯点赞的数量需要知道所有评论的id
|
|
/* //删除该资讯点赞的数量需要知道所有评论的id
|
|
//首先获取该文章资讯的总点赞数量
|
|
//首先获取该文章资讯的总点赞数量
|
|
Integer likeCount = redisCache.getCacheObject(ONE_LIKE_COUNT + communityId);
|
|
Integer likeCount = redisCache.getCacheObject(ONE_LIKE_COUNT + communityId);
|
|
@@ -226,10 +237,12 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
|
|
if (communityIdList.contains(commentChildrenVo.getId())) {
|
|
if (communityIdList.contains(commentChildrenVo.getId())) {
|
|
commentChildrenVo.setIsLike("Y");
|
|
commentChildrenVo.setIsLike("Y");
|
|
}
|
|
}
|
|
- //是否是自己的评论
|
|
|
|
- if (commentChildrenVo.getCommentUser().getId().equals(userId)){
|
|
|
|
- commentChildrenVo.setIsMyself("Y");
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (CommentChildrenVo commentChildrenVo : allComment) {
|
|
|
|
+ //是否是自己的评论
|
|
|
|
+ if (commentChildrenVo.getCommentUser().getId().equals(userId)) {
|
|
|
|
+ commentChildrenVo.setIsMyself("Y");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -257,9 +270,9 @@ public class CommentIndexServiceImpl implements ICommentIndexService {
|
|
commentIndexVo.setIsLike("Y");
|
|
commentIndexVo.setIsLike("Y");
|
|
}
|
|
}
|
|
//是否是自己的评论
|
|
//是否是自己的评论
|
|
- if (commentIndexVo.getCommentUser().getId().equals(userId)){
|
|
|
|
- commentIndexVo.setIsMyself("Y");
|
|
|
|
- }
|
|
|
|
|
|
+ if (commentIndexVo.getCommentUser().getId().equals(userId)) {
|
|
|
|
+ commentIndexVo.setIsMyself("Y");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|