|
@@ -610,30 +610,43 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @param communityArticleComment
|
|
|
|
|
|
+ * 判断评论的人 是否在文章作者的关注列表中
|
|
|
|
+ * @param userId 必填
|
|
|
|
+ * @param commentId 可选 评论的评论接口
|
|
|
|
+ * @param articleId 可选 文章评论接口
|
|
|
|
+ * @return true or false
|
|
* @throws ParseException
|
|
* @throws ParseException
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Boolean checkCommentPermission(CommunityArticleComment communityArticleComment) throws ParseException {
|
|
|
|
|
|
+ public Boolean checkCommentPermission(Long userId,Long commentId,Long articleId) throws ParseException {
|
|
/**
|
|
/**
|
|
- * 1.获取文章创建人ID
|
|
|
|
- * 2.通过文章创建人ID 查询隐私设置表 communityPrivacyService.selectUserPrivacy
|
|
|
|
- * 3.查询权限表有没有开权限
|
|
|
|
- * 4.获取用户关注列表
|
|
|
|
- * 5.是否是关注的人评论我 有则评论成功,没有则返回失败
|
|
|
|
|
|
+ * 1.传commentId 说明是 评论的评论接口
|
|
|
|
+ * 2.传articleId 说明是文章评论接口
|
|
|
|
+ * 3.询隐私设置表 communityPrivacyService.selectUserPrivacy 权限有没有开启
|
|
|
|
+ * 4.没有开启 直接结束
|
|
|
|
+ * 5.开启 查询作者关注列表
|
|
|
|
+ * 6。是否是关注的人评论我 有则评论成功,没有则返回失败
|
|
*/
|
|
*/
|
|
|
|
+ //假设传的评论ID 根据 评论ID要找到文章ID
|
|
|
|
+ if (articleId == null) {
|
|
|
|
+ List<CommunityArticleComment> communityArticleComments
|
|
|
|
+ = communityArticleCommentMapper
|
|
|
|
+ .selectList(new QueryWrapper<CommunityArticleComment>().eq("id", commentId));
|
|
|
|
+ CommunityArticleComment communityArticleComment = communityArticleComments.get(0);
|
|
|
|
+ articleId = communityArticleComment.getArticleId();
|
|
|
|
+ };
|
|
|
|
+
|
|
//获取文章信息 找到文章创建人
|
|
//获取文章信息 找到文章创建人
|
|
List<CommunityArticle> communityArticles
|
|
List<CommunityArticle> communityArticles
|
|
= communityArticleMapper
|
|
= communityArticleMapper
|
|
- .selectList(new QueryWrapper<CommunityArticle>().eq("id", communityArticleComment.getArticleId()));
|
|
|
|
|
|
+ .selectList(new QueryWrapper<CommunityArticle>().eq("id", articleId));
|
|
|
|
|
|
// 提取用户ID
|
|
// 提取用户ID
|
|
- Long articleId = null; // 初始化用户ID
|
|
|
|
|
|
+ Long articleUserId = null; // 初始化用户ID
|
|
|
|
|
|
if (!communityArticles.isEmpty()) { // 检查列表是否为空
|
|
if (!communityArticles.isEmpty()) { // 检查列表是否为空
|
|
CommunityArticle article = communityArticles.get(0); // 获取第一个文章
|
|
CommunityArticle article = communityArticles.get(0); // 获取第一个文章
|
|
- articleId = article.getUserId(); // 假设CommunityArticle有getUserId()方法
|
|
|
|
|
|
+ articleUserId = article.getUserId(); // 假设CommunityArticle有getUserId()方法
|
|
} else {
|
|
} else {
|
|
// 处理未找到文章的情况
|
|
// 处理未找到文章的情况
|
|
// 例如,可以抛出异常或记录日志
|
|
// 例如,可以抛出异常或记录日志
|
|
@@ -641,15 +654,15 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
}
|
|
}
|
|
|
|
|
|
// 直接允许作者评论
|
|
// 直接允许作者评论
|
|
- if (articleId.equals(SecurityUtils.getLoginUser().getUserId())) {
|
|
|
|
|
|
+ if (articleUserId.equals(userId)) {
|
|
/* // 如果评论者是文章作者,直接进行评论
|
|
/* // 如果评论者是文章作者,直接进行评论
|
|
communityArticleService.sendComment(communityArticleComment);*/
|
|
communityArticleService.sendComment(communityArticleComment);*/
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- // 1. 查询隐私设置
|
|
|
|
- List<CommunityUserPrivacyVo> communityUserPrivacyVos = communityPrivacyService.selectUserPrivacy(articleId);
|
|
|
|
- // 2. 检查隐私设置 只允许我关注的人评论我
|
|
|
|
|
|
+ // 查询隐私设置
|
|
|
|
+ List<CommunityUserPrivacyVo> communityUserPrivacyVos = communityPrivacyService.selectUserPrivacy(articleUserId);
|
|
|
|
+ // 检查隐私设置 只允许我关注的人评论我
|
|
boolean IsComment = false;
|
|
boolean IsComment = false;
|
|
for (CommunityUserPrivacyVo privacyVo : communityUserPrivacyVos) {
|
|
for (CommunityUserPrivacyVo privacyVo : communityUserPrivacyVos) {
|
|
if (privacyVo.getIsComment() != null && privacyVo.getIsComment()) {
|
|
if (privacyVo.getIsComment() != null && privacyVo.getIsComment()) {
|
|
@@ -659,11 +672,11 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
}
|
|
}
|
|
// 如果评论受限,则查询用户关注列表
|
|
// 如果评论受限,则查询用户关注列表
|
|
if (IsComment) {
|
|
if (IsComment) {
|
|
- List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleId);
|
|
|
|
|
|
+ List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleUserId);
|
|
// 3. 检查评论者是否在关注列表中
|
|
// 3. 检查评论者是否在关注列表中
|
|
boolean isFollower = communityUserLikeVos.stream()
|
|
boolean isFollower = communityUserLikeVos.stream()
|
|
- .anyMatch(like -> like.getLikeUserId().equals(SecurityUtils.getLoginUser().getUserId()));
|
|
|
|
- System.out.println(SecurityUtils.getLoginUser().getUserId());
|
|
|
|
|
|
+ .anyMatch(like -> like.getLikeUserId().equals(userId));
|
|
|
|
+ System.out.println(userId);
|
|
// 如果不是关注者,返回失败
|
|
// 如果不是关注者,返回失败
|
|
if (!isFollower) {
|
|
if (!isFollower) {
|
|
//return AjaxResult.error("您没有权限评论此文章,因为只允许关注的人评论您!");
|
|
//return AjaxResult.error("您没有权限评论此文章,因为只允许关注的人评论您!");
|
|
@@ -673,6 +686,10 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 判断是否是视频文件
|
|
* 判断是否是视频文件
|