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