|
@@ -77,6 +77,15 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
@Autowired
|
|
@Autowired
|
|
private CommunityUserInfoMapper communityUserInfoMapper;
|
|
private CommunityUserInfoMapper communityUserInfoMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommunityArticleCircleService communityArticleCircleService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CommunityCollectionArticleMapper communityCollectionArticleMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ICommunityCollectionArticleService collectionArticleService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询文章列表
|
|
* 查询文章列表
|
|
*
|
|
*
|
|
@@ -124,6 +133,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, circleIds, offset, pageSize, searchType);
|
|
communityArticleVos = communityArticleMapper.selectCommunityArticleList(communityArticle, circleIds, offset, pageSize, searchType);
|
|
for (CommunityArticleVo articleVo : communityArticleVos) {
|
|
for (CommunityArticleVo articleVo : communityArticleVos) {
|
|
List<Map<String, Object>> imageList = articleVo.getImageList();
|
|
List<Map<String, Object>> imageList = articleVo.getImageList();
|
|
|
|
+ articleVo.setCircleIds(circleIds);
|
|
List<CommunityArticleImages> videoList = new ArrayList<>();
|
|
List<CommunityArticleImages> videoList = new ArrayList<>();
|
|
CommunityArticleImages videos = null;
|
|
CommunityArticleImages videos = null;
|
|
for (Map<String, Object> image : imageList) {
|
|
for (Map<String, Object> image : imageList) {
|
|
@@ -140,15 +150,9 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
articleVo.setVideoList(videoList);
|
|
articleVo.setVideoList(videoList);
|
|
|
|
|
|
//设置文章的点赞数量
|
|
//设置文章的点赞数量
|
|
- articleVo.setLikeCount(communityLikeMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityLike>()
|
|
|
|
- .eq("article_id", articleVo.getId()))
|
|
|
|
- .size());
|
|
|
|
|
|
+ articleVo.setLikeCount(communityLikeMapper.selectList(new QueryWrapper<CommunityLike>().eq("article_id", articleVo.getId())).size());
|
|
|
|
|
|
- articleVo.setCollectCount(communityCollectMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityArticleCollect>()
|
|
|
|
- .eq("article_id", articleVo.getId()))
|
|
|
|
- .size());
|
|
|
|
|
|
+ articleVo.setCollectCount(communityCollectMapper.selectList(new QueryWrapper<CommunityArticleCollect>().eq("article_id", articleVo.getId())).size());
|
|
|
|
|
|
//文章下的评论
|
|
//文章下的评论
|
|
List<Map<String, Object>> comments = articleVo.getComments();
|
|
List<Map<String, Object>> comments = articleVo.getComments();
|
|
@@ -162,36 +166,23 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
communityArticleCommentVo.put("username", sysUser.getUserName());
|
|
communityArticleCommentVo.put("username", sysUser.getUserName());
|
|
communityArticleCommentVo.put("avatar", sysUser.getAvatar());
|
|
communityArticleCommentVo.put("avatar", sysUser.getAvatar());
|
|
//当前登录用户是否已点赞
|
|
//当前登录用户是否已点赞
|
|
- List<CommunityCommentLike> commentLikes = communityCommentLikeMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityCommentLike>()
|
|
|
|
- .eq("comment_id", communityArticleCommentVo.get("id")).eq("user_id", userId));
|
|
|
|
|
|
+ List<CommunityCommentLike> commentLikes = communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("comment_id", communityArticleCommentVo.get("id")).eq("user_id", userId));
|
|
communityArticleCommentVo.put("commentLike", !commentLikes.isEmpty());
|
|
communityArticleCommentVo.put("commentLike", !commentLikes.isEmpty());
|
|
|
|
|
|
//该评论的点赞数量
|
|
//该评论的点赞数量
|
|
- communityArticleCommentVo.put("commentLikeCount", communityCommentLikeMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityCommentLike>()
|
|
|
|
- .eq("comment_id", communityArticleCommentVo.get("id")))
|
|
|
|
- .size());
|
|
|
|
|
|
+ communityArticleCommentVo.put("commentLikeCount", communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("comment_id", communityArticleCommentVo.get("id"))).size());
|
|
}
|
|
}
|
|
|
|
|
|
//判断是否已收藏
|
|
//判断是否已收藏
|
|
- CommunityArticleCollect collect = communityCollectMapper
|
|
|
|
- .selectOne(new QueryWrapper<CommunityArticleCollect>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("article_id", articleVo.getId()));
|
|
|
|
|
|
+ CommunityArticleCollect collect = communityCollectMapper.selectOne(new QueryWrapper<CommunityArticleCollect>().eq("user_id", userId).eq("article_id", articleVo.getId()));
|
|
articleVo.setCollect(!Objects.isNull(collect));
|
|
articleVo.setCollect(!Objects.isNull(collect));
|
|
|
|
|
|
//判断是否已点赞
|
|
//判断是否已点赞
|
|
- CommunityLike like = communityLikeMapper
|
|
|
|
- .selectOne(new QueryWrapper<CommunityLike>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("article_id", articleVo.getId()));
|
|
|
|
|
|
+ CommunityLike like = communityLikeMapper.selectOne(new QueryWrapper<CommunityLike>().eq("user_id", userId).eq("article_id", articleVo.getId()));
|
|
articleVo.setLike(!Objects.isNull(like));
|
|
articleVo.setLike(!Objects.isNull(like));
|
|
|
|
|
|
//获取文章标签
|
|
//获取文章标签
|
|
- List<CommunityArticleTag> articleTags = communityArticleTagMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityArticleTag>()
|
|
|
|
- .eq("article_id", articleVo.getId()));
|
|
|
|
|
|
+ List<CommunityArticleTag> articleTags = communityArticleTagMapper.selectList(new QueryWrapper<CommunityArticleTag>().eq("article_id", articleVo.getId()));
|
|
List<Long> tagIds = new ArrayList<>();
|
|
List<Long> tagIds = new ArrayList<>();
|
|
for (CommunityArticleTag articleTag : articleTags) {
|
|
for (CommunityArticleTag articleTag : articleTags) {
|
|
tagIds.add(articleTag.getTagId());
|
|
tagIds.add(articleTag.getTagId());
|
|
@@ -254,6 +245,34 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
articleImages.setCreateBy(userId);
|
|
articleImages.setCreateBy(userId);
|
|
communityArticleImagesMapper.insert(articleImages);
|
|
communityArticleImagesMapper.insert(articleImages);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //插入圈子
|
|
|
|
+ List<String> circleIds = communityArticle.getCircleIds();
|
|
|
|
+ List<CommunityArticleCircle> articleCircles = new ArrayList<>();
|
|
|
|
+ CommunityArticleCircle articleCircle = null;
|
|
|
|
+ for (String circleId : circleIds) {
|
|
|
|
+ articleCircle = new CommunityArticleCircle();
|
|
|
|
+ articleCircle.setCircleId(Long.parseLong(circleId));
|
|
|
|
+ articleCircle.setArticleId(communityArticle.getId());
|
|
|
|
+ articleCircle.setCreateBy(userId);
|
|
|
|
+ articleCircle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ articleCircles.add(articleCircle);
|
|
|
|
+ }
|
|
|
|
+ communityArticleCircleService.saveBatch(articleCircles);
|
|
|
|
+
|
|
|
|
+ //插入合集
|
|
|
|
+ List<String> collectionIds = communityArticle.getCollectionIds();
|
|
|
|
+ List<CommunityCollectionArticle> collectionArticles = new ArrayList<>();
|
|
|
|
+ CommunityCollectionArticle collectionArticle = null;
|
|
|
|
+ for (String collectionId : collectionIds) {
|
|
|
|
+ collectionArticle = new CommunityCollectionArticle();
|
|
|
|
+ collectionArticle.setCollectionId(Long.parseLong(collectionId));
|
|
|
|
+ collectionArticle.setArticleId(communityArticle.getId());
|
|
|
|
+ collectionArticle.setCreateBy(userId);
|
|
|
|
+ collectionArticle.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
|
|
+ collectionArticles.add(collectionArticle);
|
|
|
|
+ }
|
|
|
|
+ collectionArticleService.saveBatch(collectionArticles);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -329,10 +348,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public CommunityArticleCollect selectCommunityCollectById(CommunityArticleCollect collect) {
|
|
public CommunityArticleCollect selectCommunityCollectById(CommunityArticleCollect collect) {
|
|
- return communityCollectMapper
|
|
|
|
- .selectOne(new QueryWrapper<CommunityArticleCollect>()
|
|
|
|
- .eq("article_id", collect.getArticleId())
|
|
|
|
- .eq("user_id", SecurityUtils.getUserId()));
|
|
|
|
|
|
+ return communityCollectMapper.selectOne(new QueryWrapper<CommunityArticleCollect>().eq("article_id", collect.getArticleId()).eq("user_id", SecurityUtils.getUserId()));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -366,9 +382,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<CommunityCircleVo> selectCommunityCircleList(String classId) {
|
|
public List<CommunityCircleVo> selectCommunityCircleList(String classId) {
|
|
- List<CommunityClassCircle> classes = communityClassCircleMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityClassCircle>()
|
|
|
|
- .eq("class_id", classId));
|
|
|
|
|
|
+ List<CommunityClassCircle> classes = communityClassCircleMapper.selectList(new QueryWrapper<CommunityClassCircle>().eq("class_id", classId));
|
|
List<Long> circleIds = new ArrayList<>();
|
|
List<Long> circleIds = new ArrayList<>();
|
|
for (CommunityClassCircle aClass : classes) {
|
|
for (CommunityClassCircle aClass : classes) {
|
|
circleIds.add(aClass.getCircleId());
|
|
circleIds.add(aClass.getCircleId());
|
|
@@ -385,11 +399,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
BeanUtils.copyProperties(communityCircle, communityCircleVo);
|
|
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));
|
|
|
|
|
|
+ CommunityUserCircle communityUserCircles = communityUserCircleMapper.selectOne(new QueryWrapper<CommunityUserCircle>().eq("circle_id", communityCircle.getId()).eq("user_id", SecurityUtils.getLoginUser().getUserId()).eq("is_delete", 0));
|
|
if (Objects.isNull(communityUserCircles) || Objects.isNull(communityUserCircles.getId())) {
|
|
if (Objects.isNull(communityUserCircles) || Objects.isNull(communityUserCircles.getId())) {
|
|
//没找到关注数据,则设为false,反之则true
|
|
//没找到关注数据,则设为false,反之则true
|
|
communityCircleVo.setLike(false);
|
|
communityCircleVo.setLike(false);
|
|
@@ -412,9 +422,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
public CommunityUserLike addOrDeleteUserLike(Long likeUserId) {
|
|
public CommunityUserLike addOrDeleteUserLike(Long likeUserId) {
|
|
Long userId = SecurityUtils.getLoginUser().getUserId(); // 当前登录用户id
|
|
Long userId = SecurityUtils.getLoginUser().getUserId(); // 当前登录用户id
|
|
//1.检查是否已被当前用户关注
|
|
//1.检查是否已被当前用户关注
|
|
- CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("like_user_id", likeUserId));
|
|
|
|
|
|
+ CommunityUserLike communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>().eq("user_id", userId).eq("like_user_id", likeUserId));
|
|
//2.1 没有则进行关注,返回关注列表信息
|
|
//2.1 没有则进行关注,返回关注列表信息
|
|
if (Objects.isNull(communityUserLike) || Objects.isNull(communityUserLike.getId())) {
|
|
if (Objects.isNull(communityUserLike) || Objects.isNull(communityUserLike.getId())) {
|
|
communityUserLike = new CommunityUserLike();
|
|
communityUserLike = new CommunityUserLike();
|
|
@@ -424,9 +432,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
communityUserLike.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
communityUserLike.setCreateTime(DateUtils.parseDate(DateUtils.getTime()));
|
|
communityUserLikeMapper.insert(communityUserLike);
|
|
communityUserLikeMapper.insert(communityUserLike);
|
|
|
|
|
|
- communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>()
|
|
|
|
- .eq("user_id", userId)
|
|
|
|
- .eq("like_user_id", likeUserId));
|
|
|
|
|
|
+ communityUserLike = communityUserLikeMapper.selectOne(new QueryWrapper<CommunityUserLike>().eq("user_id", userId).eq("like_user_id", likeUserId));
|
|
return communityUserLike;
|
|
return communityUserLike;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -444,8 +450,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
@Override
|
|
@Override
|
|
public CommunityUserInfoVo selectCommunityUserInfoById(Long userId) {
|
|
public CommunityUserInfoVo selectCommunityUserInfoById(Long userId) {
|
|
SysUser sysUser = sysUserMapper.selectUserById(userId);
|
|
SysUser sysUser = sysUserMapper.selectUserById(userId);
|
|
- CommunityUserInfo communityUserInfo = communityUserInfoMapper
|
|
|
|
- .selectOne(new QueryWrapper<CommunityUserInfo>().eq("user_id", userId));
|
|
|
|
|
|
+ CommunityUserInfo communityUserInfo = communityUserInfoMapper.selectOne(new QueryWrapper<CommunityUserInfo>().eq("user_id", userId));
|
|
CommunityUserInfoVo communityUserInfoVo = new CommunityUserInfoVo();
|
|
CommunityUserInfoVo communityUserInfoVo = new CommunityUserInfoVo();
|
|
BeanUtils.copyProperties(communityUserInfo, communityUserInfoVo);
|
|
BeanUtils.copyProperties(communityUserInfo, communityUserInfoVo);
|
|
communityUserInfoVo.setAvatar(sysUser.getAvatar());
|
|
communityUserInfoVo.setAvatar(sysUser.getAvatar());
|
|
@@ -453,12 +458,8 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
communityUserInfoVo.setUserId(userId);
|
|
communityUserInfoVo.setUserId(userId);
|
|
|
|
|
|
//设置关注,粉丝,陪伴数量
|
|
//设置关注,粉丝,陪伴数量
|
|
- communityUserInfoVo.setLikeCount(communityUserLikeMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityUserLike>()
|
|
|
|
- .eq("user_id", userId)).size());
|
|
|
|
- communityUserInfoVo.setFansCount(communityUserLikeMapper
|
|
|
|
- .selectList(new QueryWrapper<CommunityUserLike>()
|
|
|
|
- .eq("like_user_id", userId)).size());
|
|
|
|
|
|
+ communityUserInfoVo.setLikeCount(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().eq("user_id", userId)).size());
|
|
|
|
+ communityUserInfoVo.setFansCount(communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().eq("like_user_id", userId)).size());
|
|
communityUserInfoVo.setCompanionCount(0);
|
|
communityUserInfoVo.setCompanionCount(0);
|
|
|
|
|
|
//设置是否被当前登录的用户关注
|
|
//设置是否被当前登录的用户关注
|