diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicFollowQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicFollowQryExe.java index 17401a19..583a344d 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicFollowQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicFollowQryExe.java @@ -59,17 +59,25 @@ public class DynamicFollowQryExe { private final DynamicTimelineService dynamicTimelineService; private final UserProfileAppConvertor userProfileAppConvertor; private final UserSubscriptionService userSubscriptionService; + private final com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService shieldBlackService; public PageResult execute(DynamicLimitCmd cmd) { - // 获取关注人列表 + // 获取黑名单用户列表 + List blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); + Set blackUserSet = CollectionUtils.isEmpty(blackUserIds) ? Sets.newHashSet() : Sets.newHashSet(blackUserIds); + + // 获取关注人列表,过滤黑名单用户 List userSubscriptions = userSubscriptionService .listByUserId(cmd.requiredReqUserId(), null, null); if (CollectionUtils.isEmpty(userSubscriptions)) { return PageResult.newPageResult(0); } - List list = userSubscriptions.stream().map(UserSubscription::getSubscribeUserId).toList(); + List list = userSubscriptions.stream() + .map(UserSubscription::getSubscribeUserId) + .filter(userId -> !blackUserSet.contains(userId)) + .toList(); PageResult timelines = dynamicTimelineService .pageByTimeDesc(list, userRegionGateway.getRegionId(cmd.getReqUserId()), cmd.getPageReq(), Boolean.TRUE); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicLatestQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicLatestQryExe.java index 3742228c..75c4c216 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicLatestQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicLatestQryExe.java @@ -53,11 +53,13 @@ public class DynamicLatestQryExe { private final DynamicCommentService dynamicCommentService; private final UserSubscriptionService userSubscriptionService; private final UserProfileAppConvertor userProfileAppConvertor; + private final com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService shieldBlackService; public PageResult execute(DynamicLimitCmd cmd) { + List blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); PageResult dynamics = dynamicContentService - .pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin()); + .pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin(), blackUserIds); if (CollectionUtils.isEmpty(dynamics.getRecords())) { return PageResult.newPageResult(0); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicContentService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicContentService.java index 662400a0..4971cfce 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicContentService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicContentService.java @@ -36,6 +36,16 @@ public interface DynamicContentService extends BaseService { */ PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin); + /** + * 获得分页数据(排除黑名单用户) + * + * @param pageQuery 分页参数 + * @param region 地区 + * @param sysOrigin 系统来源 + * @param blackUserIds 黑名单用户ID列表 + */ + PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List blackUserIds); + /** * 获得分页数据 * diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicContentServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicContentServiceImpl.java index ba4865b1..7b2e903e 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicContentServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicContentServiceImpl.java @@ -67,6 +67,18 @@ public class DynamicContentServiceImpl extends .page(pageQuery); } + @Override + public PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List blackUserIds) { + + return query() + .eq(DynamicContent::getDel, Boolean.FALSE) + .eq(DynamicContent::getSysOrigin, sysOrigin) + .eq(region != null, DynamicContent::getRegion, region) + .notIn(CollectionUtils.isNotEmpty(blackUserIds), DynamicContent::getCreateUser, blackUserIds) + .orderByDesc(DynamicContent::getCreateTime) + .page(pageQuery); + } + @Override public PageResult pageByTimeDesc(Long userId, PageQuery pageQuery) { diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ShieldBlackService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ShieldBlackService.java index 73975aeb..8ee8f0d9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ShieldBlackService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ShieldBlackService.java @@ -70,4 +70,12 @@ public interface ShieldBlackService extends BaseService { */ List pageUserBlacklist(Long userId, Long searchUserId, Long lastId); + /** + * 获取用户所有黑名单用户ID列表. + * + * @param userId 用户id + * @return 黑名单用户ID列表 + */ + List listBlackUserIds(Long userId); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ShieldBlackServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ShieldBlackServiceImpl.java index 013d355f..adf9225a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ShieldBlackServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/ShieldBlackServiceImpl.java @@ -110,5 +110,21 @@ public class ShieldBlackServiceImpl extends BaseServiceImpl listBlackUserIds(Long userId) { + if (Objects.isNull(userId)) { + return CollectionUtils.newArrayList(); + } + + return Optional.ofNullable(query() + .select(ShieldBlack::getShieldUserId) + .eq(ShieldBlack::getUserId, userId) + .list()) + .orElse(CollectionUtils.newArrayList()) + .stream() + .map(ShieldBlack::getShieldUserId) + .filter(Objects::nonNull) + .toList(); + } }