动态列表排除待审核的动态

This commit is contained in:
tianfeng 2026-02-04 16:16:30 +08:00
parent ed7789adda
commit 373cc4f486
12 changed files with 140 additions and 29 deletions

View File

@ -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.DynamicTag;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicTimeline; 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.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.DynamicCommentService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; 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.DynamicLikeService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService; 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.DynamicTagService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTimelineService; 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.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.UserProfileDTO;
import com.red.circle.other.inner.model.dto.user.UserSimpleProfileDTO; import com.red.circle.other.inner.model.dto.user.UserSimpleProfileDTO;
@ -59,7 +61,8 @@ public class DynamicFollowQryExe {
private final DynamicTimelineService dynamicTimelineService; private final DynamicTimelineService dynamicTimelineService;
private final UserProfileAppConvertor userProfileAppConvertor; private final UserProfileAppConvertor userProfileAppConvertor;
private final UserSubscriptionService userSubscriptionService; 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<DynamicListCO> execute(DynamicLimitCmd cmd) { public PageResult<DynamicListCO> execute(DynamicLimitCmd cmd) {
@ -67,6 +70,9 @@ public class DynamicFollowQryExe {
List<Long> blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); List<Long> blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId());
Set<Long> blackUserSet = CollectionUtils.isEmpty(blackUserIds) ? Sets.newHashSet() : Sets.newHashSet(blackUserIds); Set<Long> blackUserSet = CollectionUtils.isEmpty(blackUserIds) ? Sets.newHashSet() : Sets.newHashSet(blackUserIds);
// 获取待审核动态列表
List<Long> pendingDynamicIds = approvalDynamicContentService.listPendingDynamicIds();
// 获取关注人列表过滤黑名单用户 // 获取关注人列表过滤黑名单用户
List<UserSubscription> userSubscriptions = userSubscriptionService List<UserSubscription> userSubscriptions = userSubscriptionService
.listByUserId(cmd.requiredReqUserId(), null, null); .listByUserId(cmd.requiredReqUserId(), null, null);
@ -79,8 +85,7 @@ public class DynamicFollowQryExe {
.filter(userId -> !blackUserSet.contains(userId)) .filter(userId -> !blackUserSet.contains(userId))
.toList(); .toList();
PageResult<DynamicTimeline> timelines = dynamicTimelineService PageResult<DynamicTimeline> timelines = dynamicTimelineService
.pageByTimeDesc(list, null, .pageByTimeDesc(list, null, cmd.getPageReq(), Boolean.TRUE, pendingDynamicIds);
cmd.getPageReq(), Boolean.TRUE);
if (CollectionUtils.isEmpty(timelines.getRecords())) { if (CollectionUtils.isEmpty(timelines.getRecords())) {
return PageResult.newPageResult(0); return PageResult.newPageResult(0);
@ -106,33 +111,44 @@ public class DynamicFollowQryExe {
Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(contentIds); Map<Long, Integer> commentQuantityMap = dynamicCommentService.mapCommentQuantity(contentIds);
Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(contentIds); Map<Long, List<DynamicPicture>> pictureMap = dynamicPictureService.mapPreviewGroup(contentIds);
return timelines.convert(timeline -> { List<DynamicListCO> listCOList = timelines.getRecords().stream().map(timeline -> {
DynamicContent dynamic = contentMap.get(timeline.getDynamicContentId()); DynamicContent dynamic = contentMap.get(timeline.getDynamicContentId());
if (Objects.isNull(dynamic) || dynamic.getDel()) { if (Objects.isNull(dynamic) || dynamic.getDel()) {
return null; return null;
} }
UserProfileDTO baseInfo = userProfileAppConvertor.toUserProfileDTO( UserProfileDTO baseInfo = userProfileAppConvertor.toUserProfileDTO(
userMap.get(dynamic.getCreateUser())); userMap.get(dynamic.getCreateUser()));
if (Objects.isNull(baseInfo)) {
return null;
}
DynamicListCO result = new DynamicListCO(); DynamicListCO result = new DynamicListCO();
UserSimpleProfileDTO userProfile = userProfileMap.get(dynamic.getCreateUser()); UserSimpleProfileDTO userProfile = userProfileMap.get(dynamic.getCreateUser());
if (Objects.nonNull(userProfile)) { if (Objects.nonNull(userProfile)) {
result.setUserProfile(userProfile); result.setUserProfile(userProfile);
} }
if (Objects.nonNull(baseInfo)) {
processUser(baseInfo, result);
}
processBase(dynamic, result, pictureMap); processBase(dynamic, result, pictureMap);
processUser(baseInfo, result);
processTag(tagMap, dynamic, result); processTag(tagMap, dynamic, result);
result.setSubscription(Boolean.TRUE); result.setSubscription(Boolean.TRUE);
result.setLikeStrQuantity(NumUtils.formatLong(likeQuantityMap.get(dynamic.getId()))); result.setLikeStrQuantity(NumUtils.formatLong(likeQuantityMap.get(dynamic.getId())));
result.setLike(Optional.ofNullable(likeMap.get(dynamic.getId())).orElse(Boolean.FALSE)); result.setLike(Optional.ofNullable(likeMap.get(dynamic.getId())).orElse(Boolean.FALSE));
result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId()))); result.setCommentStrQuantity(NumUtils.formatInt(commentQuantityMap.get(dynamic.getId())));
return result; return result;
}); }).filter(Objects::nonNull).toList();
PageResult<DynamicListCO> result = new PageResult<>();
result.setRecords(listCOList);
result.setTotal(timelines.getTotal());
result.setCurrent(timelines.getCurrent());
result.setSize(timelines.getSize());
return result;
} }

View File

@ -1,23 +1,22 @@
package com.red.circle.other.app.command.dynamic.query; 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.framework.dto.PageResult;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; 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.clientobject.dynamic.DynamicListCO;
import com.red.circle.other.app.dto.cmd.dynamic.DynamicLimitCmd; 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.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; 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.DynamicContent;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicPicture; 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.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.DynamicCommentService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService; 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.DynamicLikeService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService; 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.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.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.other.inner.model.dto.user.UserSimpleProfileDTO;
import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.num.NumUtils; import com.red.circle.tool.core.num.NumUtils;
@ -53,13 +52,15 @@ public class DynamicLatestQryExe {
private final DynamicCommentService dynamicCommentService; private final DynamicCommentService dynamicCommentService;
private final UserSubscriptionService userSubscriptionService; private final UserSubscriptionService userSubscriptionService;
private final UserProfileAppConvertor userProfileAppConvertor; 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<DynamicListCO> execute(DynamicLimitCmd cmd) { public PageResult<DynamicListCO> execute(DynamicLimitCmd cmd) {
List<Long> blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId()); List<Long> blackUserIds = shieldBlackService.listBlackUserIds(cmd.getReqUserId());
List<Long> pendingDynamicIds = approvalDynamicContentService.listPendingDynamicIds();
PageResult<DynamicContent> dynamics = dynamicContentService PageResult<DynamicContent> dynamics = dynamicContentService
.pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin(), blackUserIds); .pageByTimeDesc(cmd.getPageReq(), null, cmd.requireReqSysOrigin(), blackUserIds, pendingDynamicIds);
if (CollectionUtils.isEmpty(dynamics.getRecords())) { if (CollectionUtils.isEmpty(dynamics.getRecords())) {
return PageResult.newPageResult(0); return PageResult.newPageResult(0);

View File

@ -80,13 +80,12 @@ public class DynamicMessageQryExe {
} }
UserProfile user = userMap.get(message.getCreateUser()); UserProfile user = userMap.get(message.getCreateUser());
if (Objects.isNull(user)) { if (Objects.nonNull(user)) {
return null; 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; return messageCO;
}); });

View File

@ -61,7 +61,12 @@ public enum DynamicKeys implements RedisKeys {
/** /**
* 动态-点赞评论数量 * 动态-点赞评论数量
*/ */
DYNAMIC_LIKE_COMMENT_QUANTITY; DYNAMIC_LIKE_COMMENT_QUANTITY,
/**
* 动态-待审核ID列表
*/
DYNAMIC_PENDING_IDS;
@Override @Override
public String businessPrefix() { public String businessPrefix() {

View File

@ -206,4 +206,25 @@ public interface DynamicCacheService {
*/ */
Long incrUserTodayDynamicCount(Long userId); Long incrUserTodayDynamicCount(Long userId);
///////////////////////////// 动态-待审核 //////////////////////////////////////////////////////
/**
* 缓存待审核动态ID列表.
*
* @param dynamicIds 待审核动态ID列表
*/
void cachePendingDynamicIds(List<Long> dynamicIds);
/**
* 获取待审核动态ID列表.
*
* @return 待审核动态ID列表
*/
List<Long> getPendingDynamicIds();
/**
* 清除待审核动态缓存.
*/
void clearPendingDynamicIds();
} }

View File

@ -270,5 +270,25 @@ public class DynamicCacheServiceImpl implements DynamicCacheService {
return sysOrigin.concatUnderscoreJoin(DynamicKeys.DYNAMIC_TOP.name()); return sysOrigin.concatUnderscoreJoin(DynamicKeys.DYNAMIC_TOP.name());
} }
@Override
public void cachePendingDynamicIds(List<Long> 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<Long> getPendingDynamicIds() {
return Optional.ofNullable(
redisService.getStringToObject(DynamicKeys.DYNAMIC_PENDING_IDS.name(), new TypeReference<List<Long>>() {})
).orElse(CollectionUtils.newArrayList());
}
@Override
public void clearPendingDynamicIds() {
redisService.delete(DynamicKeys.DYNAMIC_PENDING_IDS.name());
}
} }

View File

@ -5,6 +5,7 @@ import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.framework.mybatis.service.BaseService;
import com.red.circle.other.infra.database.rds.entity.approval.ApprovalDynamicContent; import com.red.circle.other.infra.database.rds.entity.approval.ApprovalDynamicContent;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicQryCmd; import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicQryCmd;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -24,4 +25,11 @@ public interface ApprovalDynamicContentService extends BaseService<ApprovalDynam
void approvalNotPass(Set<Long> ids); void approvalNotPass(Set<Long> ids);
void deleteByDynamicId(Long dynamicId); void deleteByDynamicId(Long dynamicId);
/**
* 获取所有待审核的动态ID列表.
*
* @return 待审核动态ID列表
*/
List<Long> listPendingDynamicIds();
} }

View File

@ -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.LocalDateTimeUtils;
import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.text.StringUtils; import com.red.circle.tool.core.text.StringUtils;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -77,4 +78,16 @@ public class ApprovalDynamicContentServiceImpl extends
.eq(ApprovalDynamicContent::getDynamicId, dynamicId) .eq(ApprovalDynamicContent::getDynamicId, dynamicId)
.last(PageConstant.LIMIT_ONE).execute(); .last(PageConstant.LIMIT_ONE).execute();
} }
@Override
public List<Long> listPendingDynamicIds() {
return query()
.select(ApprovalDynamicContent::getDynamicId)
.eq(ApprovalDynamicContent::getApproveStatus, ApprovalStatusEnum.PENDING.name())
.list()
.stream()
.map(ApprovalDynamicContent::getDynamicId)
.filter(Objects::nonNull)
.toList();
}
} }

View File

@ -37,14 +37,16 @@ public interface DynamicContentService extends BaseService<DynamicContent> {
PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin); PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin);
/** /**
* 获得分页数据排除黑名单用户 * 获得分页数据排除黑名单用户和待审核动态
* *
* @param pageQuery 分页参数 * @param pageQuery 分页参数
* @param region 地区 * @param region 地区
* @param sysOrigin 系统来源 * @param sysOrigin 系统来源
* @param blackUserIds 黑名单用户ID列表 * @param blackUserIds 黑名单用户ID列表
* @param pendingDynamicIds 待审核动态ID列表
*/ */
PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List<Long> blackUserIds); PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin,
List<Long> blackUserIds, List<Long> pendingDynamicIds);
/** /**
* 获得分页数据 * 获得分页数据

View File

@ -49,6 +49,18 @@ public interface DynamicTimelineService extends BaseService<DynamicTimeline> {
PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery, PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery,
Boolean isOwn); Boolean isOwn);
/**
* 获得分页数据 (排除待审核动态)
*
* @param ids 用户id列表
* @param region 地区
* @param pageQuery 分页参数
* @param isOwn 是否为自己发布的动态
* @param pendingDynamicIds 待审核动态ID列表
*/
PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery,
Boolean isOwn, List<Long> pendingDynamicIds);
/** /**
* 获得自己发布过的动态 * 获得自己发布过的动态
* *

View File

@ -68,13 +68,15 @@ public class DynamicContentServiceImpl extends
} }
@Override @Override
public PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin, List<Long> blackUserIds) { public PageResult<DynamicContent> pageByTimeDesc(PageQuery pageQuery, String region, String sysOrigin,
List<Long> blackUserIds, List<Long> pendingDynamicIds) {
return query() return query()
.eq(DynamicContent::getDel, Boolean.FALSE) .eq(DynamicContent::getDel, Boolean.FALSE)
.eq(DynamicContent::getSysOrigin, sysOrigin) .eq(DynamicContent::getSysOrigin, sysOrigin)
.eq(region != null, DynamicContent::getRegion, region) .eq(region != null, DynamicContent::getRegion, region)
.notIn(CollectionUtils.isNotEmpty(blackUserIds), DynamicContent::getCreateUser, blackUserIds) .notIn(CollectionUtils.isNotEmpty(blackUserIds), DynamicContent::getCreateUser, blackUserIds)
.notIn(CollectionUtils.isNotEmpty(pendingDynamicIds), DynamicContent::getId, pendingDynamicIds)
.orderByDesc(DynamicContent::getCreateTime) .orderByDesc(DynamicContent::getCreateTime)
.page(pageQuery); .page(pageQuery);
} }

View File

@ -86,6 +86,18 @@ public class DynamicTimelineServiceImpl extends
.page(pageQuery); .page(pageQuery);
} }
@Override
public PageResult<DynamicTimeline> pageByTimeDesc(List<Long> ids, String region, PageQuery pageQuery,
Boolean isOwn, List<Long> 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 @Override
public List<DynamicTimeline> ownListByUserId(Long userId) { public List<DynamicTimeline> ownListByUserId(Long userId) {