From 373cc4f486254208f1a41fd848b5ff8b4a0dbe0f Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 4 Feb 2026 16:16:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=88=97=E8=A1=A8=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E5=BE=85=E5=AE=A1=E6=A0=B8=E7=9A=84=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dynamic/query/DynamicFollowQryExe.java | 36 +++++++++++++------ .../dynamic/query/DynamicLatestQryExe.java | 11 +++--- .../dynamic/query/DynamicMessageQryExe.java | 11 +++--- .../infra/database/cache/key/DynamicKeys.java | 7 +++- .../service/other/DynamicCacheService.java | 21 +++++++++++ .../other/impl/DynamicCacheServiceImpl.java | 20 +++++++++++ .../ApprovalDynamicContentService.java | 8 +++++ .../ApprovalDynamicContentServiceImpl.java | 13 +++++++ .../dynamic/DynamicContentService.java | 14 ++++---- .../dynamic/DynamicTimelineService.java | 12 +++++++ .../impl/DynamicContentServiceImpl.java | 4 ++- .../impl/DynamicTimelineServiceImpl.java | 12 +++++++ 12 files changed, 140 insertions(+), 29 deletions(-) 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 58771f2a..4c8e6c51 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 @@ -15,12 +15,14 @@ import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicPicture; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicTag; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicTimeline; import com.red.circle.other.infra.database.rds.entity.user.user.UserSubscription; +import com.red.circle.other.infra.database.rds.service.approval.ApprovalDynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicLikeService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTagService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTimelineService; +import com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService; import com.red.circle.other.infra.database.rds.service.user.user.UserSubscriptionService; import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserSimpleProfileDTO; @@ -59,7 +61,8 @@ 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; + private final ShieldBlackService shieldBlackService; + private final ApprovalDynamicContentService approvalDynamicContentService; public PageResult execute(DynamicLimitCmd cmd) { @@ -67,6 +70,9 @@ public class DynamicFollowQryExe { List blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); Set blackUserSet = CollectionUtils.isEmpty(blackUserIds) ? Sets.newHashSet() : Sets.newHashSet(blackUserIds); + // 获取待审核动态列表 + List pendingDynamicIds = approvalDynamicContentService.listPendingDynamicIds(); + // 获取关注人列表,过滤黑名单用户 List userSubscriptions = userSubscriptionService .listByUserId(cmd.requiredReqUserId(), null, null); @@ -79,8 +85,7 @@ public class DynamicFollowQryExe { .filter(userId -> !blackUserSet.contains(userId)) .toList(); PageResult timelines = dynamicTimelineService - .pageByTimeDesc(list, null, - cmd.getPageReq(), Boolean.TRUE); + .pageByTimeDesc(list, null, cmd.getPageReq(), Boolean.TRUE, pendingDynamicIds); if (CollectionUtils.isEmpty(timelines.getRecords())) { return PageResult.newPageResult(0); @@ -106,33 +111,44 @@ public class DynamicFollowQryExe { Map commentQuantityMap = dynamicCommentService.mapCommentQuantity(contentIds); Map> pictureMap = dynamicPictureService.mapPreviewGroup(contentIds); - return timelines.convert(timeline -> { + List listCOList = timelines.getRecords().stream().map(timeline -> { DynamicContent dynamic = contentMap.get(timeline.getDynamicContentId()); if (Objects.isNull(dynamic) || dynamic.getDel()) { return null; } + UserProfileDTO baseInfo = userProfileAppConvertor.toUserProfileDTO( - userMap.get(dynamic.getCreateUser())); - if (Objects.isNull(baseInfo)) { - return null; - } + userMap.get(dynamic.getCreateUser())); DynamicListCO result = new DynamicListCO(); UserSimpleProfileDTO userProfile = userProfileMap.get(dynamic.getCreateUser()); if (Objects.nonNull(userProfile)) { result.setUserProfile(userProfile); } + + if (Objects.nonNull(baseInfo)) { + processUser(baseInfo, result); + } + processBase(dynamic, result, pictureMap); - processUser(baseInfo, result); processTag(tagMap, dynamic, result); + result.setSubscription(Boolean.TRUE); result.setLikeStrQuantity(NumUtils.formatLong(likeQuantityMap.get(dynamic.getId()))); result.setLike(Optional.ofNullable(likeMap.get(dynamic.getId())).orElse(Boolean.FALSE)); result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId()))); return result; - }); + }).filter(Objects::nonNull).toList(); + + + PageResult result = new PageResult<>(); + result.setRecords(listCOList); + result.setTotal(timelines.getTotal()); + result.setCurrent(timelines.getCurrent()); + result.setSize(timelines.getSize()); + return result; } 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 75c4c216..29d4c27f 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 @@ -1,23 +1,22 @@ package com.red.circle.other.app.command.dynamic.query; -import com.google.common.collect.Lists; import com.red.circle.framework.dto.PageResult; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.dto.clientobject.dynamic.DynamicListCO; import com.red.circle.other.app.dto.cmd.dynamic.DynamicLimitCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; -import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicPicture; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicTag; +import com.red.circle.other.infra.database.rds.service.approval.ApprovalDynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicLikeService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTagService; +import com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService; import com.red.circle.other.infra.database.rds.service.user.user.UserSubscriptionService; -import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserSimpleProfileDTO; import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.num.NumUtils; @@ -53,13 +52,15 @@ 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; + private final ShieldBlackService shieldBlackService; + private final ApprovalDynamicContentService approvalDynamicContentService; public PageResult execute(DynamicLimitCmd cmd) { List blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); + List pendingDynamicIds = approvalDynamicContentService.listPendingDynamicIds(); PageResult dynamics = dynamicContentService - .pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin(), blackUserIds); + .pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin(), blackUserIds, pendingDynamicIds); if (CollectionUtils.isEmpty(dynamics.getRecords())) { return PageResult.newPageResult(0); diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java index b7a4e600..5289d764 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/query/DynamicMessageQryExe.java @@ -80,13 +80,12 @@ public class DynamicMessageQryExe { } UserProfile user = userMap.get(message.getCreateUser()); - if (Objects.isNull(user)) { - return null; + if (Objects.nonNull(user)) { + messageCO.setUserAvatar(user.getUserAvatar()); + messageCO.setUserNickname(user.getUserNickname()); + messageCO.setUserSex(user.getUserSex()); + messageCO.setAge(user.getAge()); } - messageCO.setUserAvatar(user.getUserAvatar()); - messageCO.setUserNickname(user.getUserNickname()); - messageCO.setUserSex(user.getUserSex()); - messageCO.setAge(user.getAge()); return messageCO; }); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/DynamicKeys.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/DynamicKeys.java index 17952541..1861226a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/DynamicKeys.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/DynamicKeys.java @@ -61,7 +61,12 @@ public enum DynamicKeys implements RedisKeys { /** * 动态-点赞评论数量 */ - DYNAMIC_LIKE_COMMENT_QUANTITY; + DYNAMIC_LIKE_COMMENT_QUANTITY, + + /** + * 动态-待审核ID列表 + */ + DYNAMIC_PENDING_IDS; @Override public String businessPrefix() { diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/DynamicCacheService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/DynamicCacheService.java index 35287a06..f65f5882 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/DynamicCacheService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/DynamicCacheService.java @@ -206,4 +206,25 @@ public interface DynamicCacheService { */ Long incrUserTodayDynamicCount(Long userId); + ///////////////////////////// 动态-待审核 ////////////////////////////////////////////////////// + + /** + * 缓存待审核动态ID列表. + * + * @param dynamicIds 待审核动态ID列表 + */ + void cachePendingDynamicIds(List dynamicIds); + + /** + * 获取待审核动态ID列表. + * + * @return 待审核动态ID列表 + */ + List getPendingDynamicIds(); + + /** + * 清除待审核动态缓存. + */ + void clearPendingDynamicIds(); + } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/DynamicCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/DynamicCacheServiceImpl.java index 957e91db..fa51cddf 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/DynamicCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/DynamicCacheServiceImpl.java @@ -270,5 +270,25 @@ public class DynamicCacheServiceImpl implements DynamicCacheService { return sysOrigin.concatUnderscoreJoin(DynamicKeys.DYNAMIC_TOP.name()); } + @Override + public void cachePendingDynamicIds(List dynamicIds) { + if (CollectionUtils.isEmpty(dynamicIds)) { + redisService.delete(DynamicKeys.DYNAMIC_PENDING_IDS.name()); + return; + } + redisService.setString(DynamicKeys.DYNAMIC_PENDING_IDS.name(), dynamicIds, 1, TimeUnit.HOURS); + } + + @Override + public List getPendingDynamicIds() { + return Optional.ofNullable( + redisService.getStringToObject(DynamicKeys.DYNAMIC_PENDING_IDS.name(), new TypeReference>() {}) + ).orElse(CollectionUtils.newArrayList()); + } + + @Override + public void clearPendingDynamicIds() { + redisService.delete(DynamicKeys.DYNAMIC_PENDING_IDS.name()); + } } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/ApprovalDynamicContentService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/ApprovalDynamicContentService.java index 6bac166e..1468a4fc 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/ApprovalDynamicContentService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/ApprovalDynamicContentService.java @@ -5,6 +5,7 @@ import com.red.circle.framework.dto.PageResult; import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.approval.ApprovalDynamicContent; import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicQryCmd; +import java.util.List; import java.util.Set; /** @@ -24,4 +25,11 @@ public interface ApprovalDynamicContentService extends BaseService ids); void deleteByDynamicId(Long dynamicId); + + /** + * 获取所有待审核的动态ID列表. + * + * @return 待审核动态ID列表 + */ + List listPendingDynamicIds(); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/impl/ApprovalDynamicContentServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/impl/ApprovalDynamicContentServiceImpl.java index a324415b..db5bd7ac 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/impl/ApprovalDynamicContentServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/approval/impl/ApprovalDynamicContentServiceImpl.java @@ -12,6 +12,7 @@ import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicQryCmd; import com.red.circle.tool.core.date.LocalDateTimeUtils; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.text.StringUtils; +import java.util.List; import java.util.Objects; import java.util.Set; import org.springframework.stereotype.Service; @@ -77,4 +78,16 @@ public class ApprovalDynamicContentServiceImpl extends .eq(ApprovalDynamicContent::getDynamicId, dynamicId) .last(PageConstant.LIMIT_ONE).execute(); } + + @Override + public List listPendingDynamicIds() { + return query() + .select(ApprovalDynamicContent::getDynamicId) + .eq(ApprovalDynamicContent::getApproveStatus, ApprovalStatusEnum.PENDING.name()) + .list() + .stream() + .map(ApprovalDynamicContent::getDynamicId) + .filter(Objects::nonNull) + .toList(); + } } 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 4971cfce..5eb74953 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 @@ -37,14 +37,16 @@ public interface DynamicContentService extends BaseService { PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin); /** - * 获得分页数据(排除黑名单用户) + * 获得分页数据(排除黑名单用户和待审核动态) * - * @param pageQuery 分页参数 - * @param region 地区 - * @param sysOrigin 系统来源 - * @param blackUserIds 黑名单用户ID列表 + * @param pageQuery 分页参数 + * @param region 地区 + * @param sysOrigin 系统来源 + * @param blackUserIds 黑名单用户ID列表 + * @param pendingDynamicIds 待审核动态ID列表 */ - PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List blackUserIds); + PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, + List blackUserIds, List pendingDynamicIds); /** * 获得分页数据 diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicTimelineService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicTimelineService.java index f2e94ed6..5ce9e331 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicTimelineService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/DynamicTimelineService.java @@ -49,6 +49,18 @@ public interface DynamicTimelineService extends BaseService { PageResult pageByTimeDesc(List ids, String region, PageQuery pageQuery, Boolean isOwn); + /** + * 获得分页数据 (排除待审核动态) + * + * @param ids 用户id列表 + * @param region 地区 + * @param pageQuery 分页参数 + * @param isOwn 是否为自己发布的动态 + * @param pendingDynamicIds 待审核动态ID列表 + */ + PageResult pageByTimeDesc(List ids, String region, PageQuery pageQuery, + Boolean isOwn, List pendingDynamicIds); + /** * 获得自己发布过的动态 * 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 7b2e903e..fae67598 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 @@ -68,13 +68,15 @@ public class DynamicContentServiceImpl extends } @Override - public PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List blackUserIds) { + public PageResult pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, + List blackUserIds, List pendingDynamicIds) { return query() .eq(DynamicContent::getDel, Boolean.FALSE) .eq(DynamicContent::getSysOrigin, sysOrigin) .eq(region != null, DynamicContent::getRegion, region) .notIn(CollectionUtils.isNotEmpty(blackUserIds), DynamicContent::getCreateUser, blackUserIds) + .notIn(CollectionUtils.isNotEmpty(pendingDynamicIds), DynamicContent::getId, pendingDynamicIds) .orderByDesc(DynamicContent::getCreateTime) .page(pageQuery); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicTimelineServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicTimelineServiceImpl.java index 46ee6c0b..5801f999 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicTimelineServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/dynamic/impl/DynamicTimelineServiceImpl.java @@ -86,6 +86,18 @@ public class DynamicTimelineServiceImpl extends .page(pageQuery); } + @Override + public PageResult pageByTimeDesc(List ids, String region, PageQuery pageQuery, + Boolean isOwn, List pendingDynamicIds) { + return query() + .in(DynamicTimeline::getCreateUser, ids) + .eq(DynamicTimeline::getOwn, isOwn) + .in(region != null, DynamicTimeline::getRegion, region, "") + .notIn(CollectionUtils.isNotEmpty(pendingDynamicIds), DynamicTimeline::getDynamicContentId, pendingDynamicIds) + .orderByDesc(DynamicTimeline::getCreateTime) + .page(pageQuery); + } + @Override public List ownListByUserId(Long userId) {