diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index a9837d6..e2baf45 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -257,14 +257,15 @@ public class MyController extends BaseController { private Result> getCollectedUserInfo(String userId, Integer pageNum, Integer pageSize, CollectTypeEnum collectTypeEnum) { Pageable pageable = PageRequest.of(pageNum-1,pageSize); - Page userCollectInfos = isGetFan(collectTypeEnum)?userCollectInfoService.findByObjectIdAndCollectType(userId,CollectTypeEnum.FOLLOWS,pageable):userCollectInfoService.findByUserIdAndCollectType(userId,collectTypeEnum,pageable); - Function idFunction=isGetFan(collectTypeEnum)?UserCollectInfo::getUserId:UserCollectInfo::getObjectId; + boolean isGetFan=isGetFan(collectTypeEnum); + Page userCollectInfos = isGetFan?userCollectInfoService.findByObjectIdAndCollectType(userId,CollectTypeEnum.FOLLOWS,pageable):userCollectInfoService.findByUserIdAndCollectType(userId,collectTypeEnum,pageable); + Function idFunction=isGetFan?UserCollectInfo::getUserId:UserCollectInfo::getObjectId; List objectIds=userCollectInfos.stream().map(idFunction).collect(Collectors.toList()); if (objectIds.isEmpty()) { return Result.success(new PageResult(0L, Collections.emptyList())); } List userInfos = userInfoService.orderByField(objectIds); - Set bothFollowSet=userCollectInfos.stream().filter(c->Boolean.TRUE.equals(c.getIsMutualFans())).map(UserCollectInfo::getObjectId).collect(Collectors.toSet()); + Set bothFollowSet=userCollectInfos.stream().filter(c->Boolean.TRUE.equals(c.getIsMutualFans())).map(u->isGetFan?u.getUserId():u.getObjectId()).collect(Collectors.toSet()); List results = userInfos.stream().map(s -> getUserRespDTO(s, false, bothFollowSet)) .collect(Collectors.toList()); return Result.success(new PageResult(Long.valueOf(results.size()), results));