|
@@ -28,6 +28,7 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -629,7 +630,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 当前用户关注列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectCommunityUserLikeList(Long userId,int pageNum, int pageSize,int searchType) {
|
|
|
+ public List<CommunityUserLikeVo> selectCommunityUserLikeList(Long userId,String userName,int pageNum, int pageSize,int searchType) {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
Page<CommunityUserLike> page = new Page<>(offset, pageSize);
|
|
|
QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
|
|
@@ -641,9 +642,10 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
}
|
|
|
List<CommunityUserLike> communityUserLikes = communityUserLikeMapper.selectPage(page, queryWrapper).getRecords();
|
|
|
|
|
|
-
|
|
|
List<CommunityUserLikeVo> communityUserLikeVos = new ArrayList<>();
|
|
|
CommunityUserLikeVo communityUserLikeVo = null;
|
|
|
+ Boolean isCare = false;
|
|
|
+
|
|
|
for (CommunityUserLike communityUserLike : communityUserLikes) {
|
|
|
communityUserLikeVo = new CommunityUserLikeVo();
|
|
|
//用户信息
|
|
@@ -654,6 +656,17 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
CommunityUserInfo likeUserInfo = communityUserInfoMapper.selectOne(new QueryWrapper<CommunityUserInfo>().eq("user_id", communityUserLike.getLikeUserId()));
|
|
|
BeanUtils.copyProperties(communityUserLike, communityUserLikeVo);
|
|
|
|
|
|
+ //关注的用户是否已经关注当前用户
|
|
|
+ CommunityUserLike communityUserLikeFans = communityUserLikeMapper.selectOne(
|
|
|
+ new QueryWrapper<CommunityUserLike>()
|
|
|
+ .eq("like_user_id", userId )
|
|
|
+ .eq("user_id", communityUserLike.getLikeUserId() ));
|
|
|
+
|
|
|
+ if (communityUserLikeFans != null){
|
|
|
+ isCare = true;
|
|
|
+ }
|
|
|
+ communityUserLikeVo.setIsCare(isCare);
|
|
|
+
|
|
|
if (Objects.nonNull(userInfo)) {
|
|
|
communityUserLikeVo.setProfile(userInfo.getProfile());
|
|
|
}
|
|
@@ -672,7 +685,13 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
communityUserLikeVo.setLikeAvatar(sysUserLike.getAvatar());
|
|
|
}
|
|
|
|
|
|
- communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ //如果不需要搜索名字直接添加
|
|
|
+ if ( userName != null && communityUserLikeVo.getLikeUsername().matches("(?i).*" + Pattern.quote(userName) + ".*") ) {
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }else if( userName == null ){
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return communityUserLikeVos;
|
|
|
}
|
|
@@ -685,7 +704,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 当前用户粉丝列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectUserFansList(Long userId,int pageNum, int pageSize,int searchType) {
|
|
|
+ public List<CommunityUserLikeVo> selectUserFansList(Long userId,String userName,int pageNum, int pageSize,int searchType) {
|
|
|
int offset = (pageNum - 1) * pageSize;
|
|
|
Page<CommunityUserLike> page = new Page<>(offset, pageSize);
|
|
|
QueryWrapper<CommunityUserLike> queryWrapper = new QueryWrapper<CommunityUserLike>()
|
|
@@ -714,8 +733,6 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
.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;
|
|
|
}
|
|
@@ -743,8 +760,13 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
if (Objects.nonNull(likeUserInfo)){
|
|
|
communityUserLikeVo.setLikeProfile(likeUserInfo.getProfile());
|
|
|
}
|
|
|
+ //如果不需要搜索名字直接添加
|
|
|
+ if ( userName != null && communityUserLikeVo.getUsername().matches("(?i).*" + Pattern.quote(userName) + ".*") ) {
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }else if( userName == null ){
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }
|
|
|
|
|
|
- communityUserLikeVos.add(communityUserLikeVo);
|
|
|
}
|
|
|
return communityUserLikeVos;
|
|
|
}
|
|
@@ -756,10 +778,10 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
* @return 获取互相关注列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CommunityUserLikeVo> selectMutualAttention(Long userId,int pageNum, int pageSize, int searchType) {
|
|
|
+ public List<CommunityUserLikeVo> selectMutualAttention(Long userId,String userName,int pageNum, int pageSize, int searchType) {
|
|
|
|
|
|
//先查询自己关注的人
|
|
|
- List<CommunityUserLikeVo> communityUserLikeVos = selectCommunityUserLikeList(userId,1,10000000,0);
|
|
|
+ List<CommunityUserLikeVo> communityUserLikeVos = selectCommunityUserLikeList(userId,null,1,10000000,0);
|
|
|
//再查询被关注的人是否关注自己
|
|
|
List<Long> likeUserIds = new ArrayList<>();
|
|
|
for (CommunityUserLikeVo communityUserLikeVo : communityUserLikeVos) {
|
|
@@ -799,8 +821,17 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
communityUserLikeVo.setLikeUsername(sysUserLike.getNickName());
|
|
|
communityUserLikeVo.setLikeAvatar(sysUserLike.getAvatar());
|
|
|
communityUserLikeVo.setLikeProfile(likeUserInfo.getProfile());
|
|
|
+ communityUserLikeVo.setIsCare(true);
|
|
|
+
|
|
|
+
|
|
|
+ //如果不需要搜索名字直接添加
|
|
|
+ if ( userName != null && communityUserLikeVo.getUsername().matches("(?i).*" + Pattern.quote(userName) + ".*") ) {
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }else if( userName == null ){
|
|
|
+ communityUserLikeVos.add(communityUserLikeVo);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- communityUserLikeVos.add(communityUserLikeVo);
|
|
|
}
|
|
|
}
|
|
|
return communityUserLikeVos;
|
|
@@ -871,7 +902,7 @@ public class CommunityArticleServiceImpl extends ServiceImpl<CommunityArticleMap
|
|
|
}
|
|
|
// 如果评论受限,则查询用户关注列表
|
|
|
if (IsComment) {
|
|
|
- List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleUserId,1,100000,0);
|
|
|
+ List<CommunityUserLikeVo> communityUserLikeVos = communityArticleService.selectCommunityUserLikeList(articleUserId,null,1,100000,0);
|
|
|
// 3. 检查评论者是否在关注列表中
|
|
|
boolean isFollower = communityUserLikeVos.stream()
|
|
|
.anyMatch(like -> like.getLikeUserId().equals(userId));
|