Commit 515714ca authored by shiyu's avatar shiyu

客态展示关注关系

parent 0e0babdf
...@@ -183,7 +183,7 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService { ...@@ -183,7 +183,7 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
} }
followFansRecordVos.add(followFansRecordVo); followFansRecordVos.add(followFansRecordVo);
}); });
List<FollowFansRecordVo> followFansRecordVoList = getCurrentFollowRelation(dto, followFansRecordVos); List<FollowFansRecordVo> followFansRecordVoList = getCurrentFollowRelation(dto, followFansRecordVos, "follow");
return Result.success(PageSearchResult.of(pageInfo, followFansRecordVoList)); return Result.success(PageSearchResult.of(pageInfo, followFansRecordVoList));
} catch (Exception e) { } catch (Exception e) {
logger.error("{} 查询关注列表 {}", dto.getId(), e); logger.error("{} 查询关注列表 {}", dto.getId(), e);
...@@ -223,7 +223,7 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService { ...@@ -223,7 +223,7 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
} }
followFansRecordVos.add(followFansRecordVo); followFansRecordVos.add(followFansRecordVo);
}); });
List<FollowFansRecordVo> followFansRecordVoList = getCurrentFollowRelation(dto, followFansRecordVos); List<FollowFansRecordVo> followFansRecordVoList = getCurrentFollowRelation(dto, followFansRecordVos, "fans");
return Result.success(PageSearchResult.of(pageInfo, followFansRecordVoList)); return Result.success(PageSearchResult.of(pageInfo, followFansRecordVoList));
} catch (Exception e) { } catch (Exception e) {
logger.error("{} 查询粉丝列表 {}", dto.getId(), e); logger.error("{} 查询粉丝列表 {}", dto.getId(), e);
...@@ -232,29 +232,34 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService { ...@@ -232,29 +232,34 @@ public class FollowFansRecordServiceImpl implements FollowFansRecordService {
} }
public List<FollowFansRecordVo> getCurrentFollowRelation(FollowFansRecordRequestDto dto, List<FollowFansRecordVo> followFansRecordVos) { public List<FollowFansRecordVo> getCurrentFollowRelation(FollowFansRecordRequestDto dto, List<FollowFansRecordVo> followFansRecordVos, String type) {
if (dto.getCurrentUserId() != null) { if (dto.getCurrentUserId() != null) {
//查询当前用户关注的人 //查询当前用户关注的人
FollowFansRecordRequestDto currentFollowDto = new FollowFansRecordRequestDto(); FollowFansRecordRequestDto currentFollowDto = new FollowFansRecordRequestDto();
dto.setFansId(dto.getCurrentUserId()); currentFollowDto.setFansId(dto.getCurrentUserId());
List<FollowFansRecord> currentFollowFansRecordList = followFansRecordDao.findList(currentFollowDto); List<FollowFansRecord> currentFollowFansRecordList = followFansRecordDao.findList(currentFollowDto);
List<Long> currentFollowIdList = currentFollowFansRecordList.stream().map(FollowFansRecord::getFollowerId).collect(Collectors.toList()); List<Long> currentFollowIdList = currentFollowFansRecordList.stream().map(FollowFansRecord::getFollowerId).collect(Collectors.toList());
//查询当前用户的粉丝 //查询当前用户的粉丝
FollowFansRecordRequestDto currentFansDto = new FollowFansRecordRequestDto(); FollowFansRecordRequestDto currentFansDto = new FollowFansRecordRequestDto();
dto.setFollowerId(dto.getCurrentUserId()); currentFansDto.setFollowerId(dto.getCurrentUserId());
List<FollowFansRecord> currentFansRecordList = followFansRecordDao.findList(currentFansDto); List<FollowFansRecord> currentFansRecordList = followFansRecordDao.findList(currentFansDto);
List<Long> currentFansIdList = currentFansRecordList.stream().map(FollowFansRecord::getFansId).collect(Collectors.toList()); List<Long> currentFansIdList = currentFansRecordList.stream().map(FollowFansRecord::getFansId).collect(Collectors.toList());
followFansRecordVos.forEach(followFansRecordVo -> { followFansRecordVos.forEach(followFansRecordVo -> {
long followerId = followFansRecordVo.getFollowerId(); long id;
if (currentFollowIdList.contains(followerId) && currentFansIdList.contains(followerId)) { if ("fans".equals(type)) {
id = followFansRecordVo.getFansId();
} else {
id = followFansRecordVo.getFollowerId();
}
if (currentFollowIdList.contains(id) && currentFansIdList.contains(id)) {
followFansRecordVo.setRelation("互相关注"); followFansRecordVo.setRelation("互相关注");
followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.BOTH_FOLLOWED.getCode()); followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.BOTH_FOLLOWED.getCode());
} else if (currentFollowIdList.contains(followerId) && !currentFansIdList.contains(followerId)) { } else if (currentFollowIdList.contains(id) && !currentFansIdList.contains(id)) {
followFansRecordVo.setRelation("已关注"); followFansRecordVo.setRelation("已关注");
followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.FOLLOWED.getCode()); followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.FOLLOWED.getCode());
} else if (!currentFollowIdList.contains(followerId) && currentFansIdList.contains(followerId)) { } else if (!currentFollowIdList.contains(id) && currentFansIdList.contains(id)) {
followFansRecordVo.setRelation("回关"); followFansRecordVo.setRelation("回关");
followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.BACK_FOLLOWED.getCode()); followFansRecordVo.setRelationCode(FollowFansEnum.RelationEnum.BACK_FOLLOWED.getCode());
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment