|
@@ -629,11 +629,17 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 当前用户关注列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectCommunityUserLikeList(Long userId,int pageNum, int pageSize) {
|
|
|
+ public List<CommunityUserLikeVo> selectCommunityUserLikeList(Long userId,int pageNum, int pageSize,int searchType) {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
Page<CommunityUserLike> page = new Page<>(offset, pageSize);
|
|
|
- List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page,new QueryWrapper<CommunityUserLike>().eq("user_id", userId)).getRecords();
|
|
|
-
|
|
|
+ QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
|
|
|
+ .eq("user_id", userId);
|
|
|
+ if (searchType == 1) {
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ } else {
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
+ }
|
|
|
+ List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
|
|
|
|
|
|
List<CommunityUserLikeVo> communityUserLikeVos = new ArrayList<>();
|
|
@@ -679,10 +685,21 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 当前用户粉丝列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectUserFansList(Long userId) {
|
|
|
- List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().eq("like_user_id", userId));
|
|
|
+ public List<CommunityUserLikeVo> selectUserFansList(Long userId,int pageNum, int pageSize,int searchType) {
|
|
|
+ int offset = (pageNum - 1) * pageSize;
|
|
|
+ Page<CommunityUserLike> page = new Page<>(offset, pageSize);
|
|
|
+ QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
|
|
|
+ .eq("like_user_id", userId);
|
|
|
+ if (searchType == 1) {
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ } else {
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
+ }
|
|
|
+ List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
+
|
|
|
List<CommunityUserLikeVo> communityUserLikeVos = new ArrayList<>();
|
|
|
CommunityUserLikeVo communityUserLikeVo = null;
|
|
|
+ Boolean isCare = false;
|
|
|
for (CommunityUserLike communityUserLike : communityUserLikes) {
|
|
|
|
|
|
//用户信息
|
|
@@ -690,10 +707,25 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
//用户自我介绍
|
|
|
CommunityUserInfo userInfo = communityUserInfoMapper.selectOne(new QueryWrapper<CommunityUserInfo>().eq("user_id", communityUserLike.getUserId()));
|
|
|
CommunityUserInfo likeUserInfo = communityUserInfoMapper.selectOne(new QueryWrapper<CommunityUserInfo>().eq("user_id", communityUserLike.getLikeUserId()));
|
|
|
+
|
|
|
+ //粉丝是否已经关注当前用户
|
|
|
+ CommunityUserLike communityUserLikeFans = communityUserLikeMapper.selectOne(
|
|
|
+ new QueryWrapper<CommunityUserLike>()
|
|
|
+ .eq("like_user_id", communityUserLike.getUserId() )
|
|
|
+ .eq("user_id", userId ));
|
|
|
+
|
|
|
+ System.out.println("like: " + communityUserLike.getUserId());
|
|
|
+ System.out.println("user_id: " + userId);
|
|
|
+ if (communityUserLikeFans != null){
|
|
|
+ isCare = true;
|
|
|
+ }
|
|
|
communityUserLikeVo = new CommunityUserLikeVo();
|
|
|
BeanUtils.copyProperties(communityUserLike, communityUserLikeVo);
|
|
|
SysUser sysUser = sysUserMapper.selectUserById(communityUserLike.getUserId());
|
|
|
|
|
|
+ communityUserLikeVo.setIsCare(isCare);
|
|
|
+
|
|
|
+
|
|
|
if (Objects.nonNull(sysUser)) {
|
|
|
communityUserLikeVo.setAvatar(sysUser.getAvatar());
|
|
|
communityUserLikeVo.setUsername(sysUser.getNickName());
|
|
@@ -724,9 +756,10 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 获取互相关注列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectMutualAttention(Long userId) {
|
|
|
+ public List<CommunityUserLikeVo> selectMutualAttention(Long userId,int pageNum, int pageSize, int searchType) {
|
|
|
+
|
|
|
//先查询自己关注的人
|
|
|
- List<CommunityUserLikeVo> communityUserLikeVos = selectCommunityUserLikeList(userId,1,10);
|
|
|
+ List<CommunityUserLikeVo> communityUserLikeVos = selectCommunityUserLikeList(userId,1,10000000,0);
|
|
|
//再查询被关注的人是否关注自己
|
|
|
List<Long> likeUserIds = new ArrayList<>();
|
|
|
for (CommunityUserLikeVo communityUserLikeVo : communityUserLikeVos) {
|
|
@@ -734,7 +767,20 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
}
|
|
|
|
|
|
if (!likeUserIds.isEmpty()) {
|
|
|
- List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectList(new QueryWrapper<CommunityUserLike>().in("user_id", likeUserIds).eq("like_user_id", userId));
|
|
|
+ QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
|
|
|
+ .in("user_id", likeUserIds).eq("like_user_id", userId);
|
|
|
+ if (searchType == 1) {
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ } else {
|
|
|
+ queryWrapper.orderByAsc("create_time");
|
|
|
+ }
|
|
|
+ //分页查询数据
|
|
|
+ int offset = (pageNum - 1) * pageSize;
|
|
|
+ Page<CommunityUserLike> page = new Page<>(offset, pageSize);
|
|
|
+ System.out.println("offset: " + offset);
|
|
|
+ List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
+
|
|
|
+ System.out.println("communityUserLikes: " + communityUserLikes);
|
|
|
CommunityUserLikeVo communityUserLikeVo = null;
|
|
|
communityUserLikeVos = new ArrayList<>();
|
|
|
for (CommunityUserLike communityUserLike : communityUserLikes) {
|
|
@@ -825,7 +871,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
}
|
|
|
// 如果评论受限,则查询用户关注列表
|
|
|
if (IsComment) {
|
|
|
- List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleUserId,1,10);
|
|
|
+ List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleUserId,1,100000,0);
|
|
|
// 3. 检查评论者是否在关注列表中
|
|
|
boolean isFollower = communityUserLikeVos.stream()
|
|
|
.anyMatch(like -> like.getLikeUserId().equals(userId));
|