|
@@ -178,6 +178,9 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
for (Long articleId : articleIds) {
|
|
|
//获取指定文章详细内容,文章浏览量+1
|
|
|
CommunityArticle article = communityArticleMapper.selectById(articleId);
|
|
|
+ if (article == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
article.setPageViews(article.getPageViews() + 1);
|
|
|
communityArticleMapper.updateById(article);
|
|
|
}
|
|
@@ -674,7 +677,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
}
|
|
|
|
|
|
|
|
|
- Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
//插入文章信息
|
|
|
communityArticle.setUserId(userId);
|
|
|
communityArticle.setCreateBy(userId);
|
|
@@ -800,7 +803,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
@Override
|
|
|
public void editCommunityArticle(CommunityArticle communityArticle) {
|
|
|
|
|
|
- Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
//编辑文章信息
|
|
|
communityArticle.setUpdateBy(userId);
|
|
|
communityArticle.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
@@ -998,8 +1001,9 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
@Override
|
|
|
public void sendComment(CommunityArticleComment communityArticleComment) throws ParseException {
|
|
|
communityArticleComment.setId(null);
|
|
|
- communityArticleComment.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
- communityArticleComment.setUpdateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ communityArticleComment.setCreateBy(userId);
|
|
|
+ communityArticleComment.setUpdateBy(userId);
|
|
|
communityArticleComment.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
communityArticleComment.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
communityArticleComment.setDelete(false);
|
|
@@ -1025,9 +1029,9 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
communityArticleAt.setType(1L);
|
|
|
communityArticleAt.setArticleId(communityArticleComment.getArticleId());
|
|
|
communityArticleAt.setCommentId(communityArticleComment.getId());
|
|
|
- communityArticleAt.setUserId(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityArticleAt.setUserId(userId);
|
|
|
communityArticleAt.setPeerId(atUserId);
|
|
|
- communityArticleAt.setCreateBy(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ communityArticleAt.setCreateBy(userId);
|
|
|
communityArticleAt.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
communityArticleAts.add(communityArticleAt);
|
|
|
}
|
|
@@ -1043,7 +1047,8 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
@Override
|
|
|
public void deleteComment(CommunityArticleComment communityArticleComment) {
|
|
|
communityArticleComment.setDelete(true);
|
|
|
- communityArticleComment.setUpdateBy(SecurityUtils.getUserId());
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ communityArticleComment.setUpdateBy(userId);
|
|
|
communityArticleComment.setUpdateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
communityArticleCommentMapper.updateById(communityArticleComment);
|
|
|
}
|
|
@@ -1146,7 +1151,8 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
BeanUtils.copyProperties(communityCircle, communityCircleVo);
|
|
|
|
|
|
//获取当前用户是否有关注这些圈子
|
|
|
- CommunityUserCircle communityUserCircles = communityUserCircleMapper.selectOne(new QueryWrapper<CommunityUserCircle>().eq("circle_id", communityCircle.getId()).eq("user_id", SecurityUtils.getLoginUser().getUserId()).eq("is_delete", 0));
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
|
+ CommunityUserCircle communityUserCircles = communityUserCircleMapper.selectOne(new QueryWrapper<CommunityUserCircle>().eq("circle_id", communityCircle.getId()).eq("user_id", userId).eq("is_delete", 0));
|
|
|
if (Objects.isNull(communityUserCircles) || Objects.isNull(communityUserCircles.getId())) {
|
|
|
//没找到关注数据,则设为false,反之则true
|
|
|
communityCircleVo.setLike(false);
|
|
@@ -1167,7 +1173,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
*/
|
|
|
@Override
|
|
|
public CommunityUserLike addOrDeleteUserLike(Long likeUserId) {
|
|
|
- Long userId = SecurityUtils.getLoginUser().getUserId(); // 当前登录用户id
|
|
|
+ Long userId = SecurityUtils.getUserId(); // 当前登录用户id
|
|
|
//1.检查是否已被当前用户关注
|
|
|
CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>().eq("user_id", userId).eq("like_user_id", likeUserId));
|
|
|
//2.1 没有则进行关注,返回关注列表信息
|
|
@@ -1242,12 +1248,17 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
//设置是否被当前登录的用户关注
|
|
|
communityUserInfoVo.setLike(false);
|
|
|
if (isToken) {
|
|
|
- Long loginUserId = SecurityUtils.getLoginUser().getUserId();
|
|
|
- if (!Objects.equals(userId, loginUserId)) {
|
|
|
- CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>().eq("user_id", loginUserId).eq("like_user_id", userId));
|
|
|
- if (!Objects.isNull(communityUserLike) && !Objects.isNull(communityUserLike.getId())) {
|
|
|
- communityUserInfoVo.setLike(true);
|
|
|
+ try {
|
|
|
+ Long loginUserId = SecurityUtils.getUserId();
|
|
|
+ if (!Objects.equals(userId, loginUserId)) {
|
|
|
+ CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>().eq("user_id", loginUserId).eq("like_user_id", userId));
|
|
|
+ if (!Objects.isNull(communityUserLike) && !Objects.isNull(communityUserLike.getId())) {
|
|
|
+ communityUserInfoVo.setLike(true);
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取当前登录用户ID失败", e);
|
|
|
+ // 如果获取用户ID失败,继续处理,不影响其他功能
|
|
|
}
|
|
|
}
|
|
|
return communityUserInfoVo;
|
|
@@ -1612,7 +1623,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
@Override
|
|
|
public List<CommunityUserPromptVo> selectCommunityUserPrompt(Long userId) {
|
|
|
if (Objects.isNull(userId)) {
|
|
|
- userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ userId = SecurityUtils.getUserId();
|
|
|
}
|
|
|
// 查询自己的通知列表
|
|
|
List<CommunityUserPrompt> communityUserPrompts
|