动态消息类型处理

This commit is contained in:
tianfeng 2026-02-02 14:06:31 +08:00
parent 6e6272bffc
commit b1cbd6b81f
10 changed files with 75 additions and 12 deletions

View File

@ -29,6 +29,11 @@ public enum DynamicMessageEnum {
*/ */
LIKE_COMMENT, LIKE_COMMENT,
/**
* 动态礼物
*/
DYNAMIC_GIFT,
/** /**
* 驳回举报. * 驳回举报.
*/ */

View File

@ -82,10 +82,12 @@ public class DynamicCommentCmdExe {
//评论不属于自己的动态发送消息 //评论不属于自己的动态发送消息
if (Objects.isNull(cmd.getToUserId())) { if (Objects.isNull(cmd.getToUserId())) {
cmd.setToUserId(dynamicContent.getCreateUser()); cmd.setToUserId(dynamicContent.getCreateUser());
saveDynamicMessage(cmd, DynamicMessageEnum.COMMENT_DYNAMIC);
} else {
//发送消息给动态被回复人
saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT);
} }
//发送消息给动态被回复人
saveDynamicMessage(cmd, DynamicMessageEnum.REPLY_COMMENT);
return convert(dynamicComment, userProfileMap); return convert(dynamicComment, userProfileMap);
} }

View File

@ -2,14 +2,17 @@ package com.red.circle.other.app.command.dynamic;
import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.common.business.enums.DynamicMessageEnum;
import com.red.circle.other.app.common.room.DynamicCommon; import com.red.circle.other.app.common.room.DynamicCommon;
import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd; import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd;
import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService; import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService;
import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService; import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicCommentLike; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicCommentLike;
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.DynamicMessage;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentLikeService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentLikeService;
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.DynamicMessageService;
import com.red.circle.other.inner.asserts.DynamicErrorCode; import com.red.circle.other.inner.asserts.DynamicErrorCode;
import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.num.NumUtils; import com.red.circle.tool.core.num.NumUtils;
@ -35,6 +38,7 @@ public class DynamicCommentLikeCmdExe {
private final DynamicContentService dynamicContentService; private final DynamicContentService dynamicContentService;
private final DynamicPopularService dynamicPopularService; private final DynamicPopularService dynamicPopularService;
private final DynamicCommentLikeService dynamicCommentLikeService; private final DynamicCommentLikeService dynamicCommentLikeService;
private final DynamicMessageService dynamicMessageService;
public Long execute(DynamicLikeCmd cmd) { public Long execute(DynamicLikeCmd cmd) {
@ -52,6 +56,9 @@ public class DynamicCommentLikeCmdExe {
//热门权重 //热门权重
updateScore(cmd, content, 1); updateScore(cmd, content, 1);
// 保存点赞评论消息
saveDynamicMessage(cmd, DynamicMessageEnum.LIKE_COMMENT);
dynamicCommon.sendMsg(cmd.getToUserId()); dynamicCommon.sendMsg(cmd.getToUserId());
return getIncrQuantity(cmd); return getIncrQuantity(cmd);
} }
@ -119,5 +126,16 @@ public class DynamicCommentLikeCmdExe {
.exist(cmd.getDynamicId(), cmd.getCommentId(), cmd.getReqUserId()); .exist(cmd.getDynamicId(), cmd.getCommentId(), cmd.getReqUserId());
} }
private void saveDynamicMessage(DynamicLikeCmd cmd, DynamicMessageEnum type) {
DynamicMessage message = new DynamicMessage();
message.setId(IdWorkerUtils.getId());
message.setDynamicContentId(cmd.getDynamicId());
message.setDynamicCommentId(cmd.getCommentId());
message.setType(type.name());
message.setToUserId(cmd.getToUserId());
message.setCreateTime(TimestampUtils.now());
message.setCreateUser(cmd.getReqUserId());
dynamicMessageService.save(message);
}
} }

View File

@ -1,14 +1,17 @@
package com.red.circle.other.app.command.dynamic; package com.red.circle.other.app.command.dynamic;
import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.common.business.enums.DynamicMessageEnum;
import com.red.circle.other.app.common.room.DynamicCommon; import com.red.circle.other.app.common.room.DynamicCommon;
import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd; import com.red.circle.other.app.dto.cmd.dynamic.DynamicLikeCmd;
import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService; import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService;
import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService; import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService;
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.DynamicLike; import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicLike;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage;
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.DynamicMessageService;
import com.red.circle.other.inner.asserts.DynamicErrorCode; import com.red.circle.other.inner.asserts.DynamicErrorCode;
import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.num.NumUtils; import com.red.circle.tool.core.num.NumUtils;
@ -34,6 +37,7 @@ public class DynamicLikeCmdExe {
private final DynamicCacheService dynamicCacheService; private final DynamicCacheService dynamicCacheService;
private final DynamicContentService dynamicContentService; private final DynamicContentService dynamicContentService;
private final DynamicPopularService dynamicPopularService; private final DynamicPopularService dynamicPopularService;
private final DynamicMessageService dynamicMessageService;
public Long execute(DynamicLikeCmd cmd) { public Long execute(DynamicLikeCmd cmd) {
@ -55,6 +59,9 @@ public class DynamicLikeCmdExe {
dynamicPopularService.updateScore(content.getId(), dynamicCacheService.getLikeScore(), dynamicPopularService.updateScore(content.getId(), dynamicCacheService.getLikeScore(),
cmd.getReqSysOrigin().getOrigin(), content.getRegion()); cmd.getReqSysOrigin().getOrigin(), content.getRegion());
// 保存点赞动态消息
saveDynamicMessage(cmd, content, DynamicMessageEnum.LIKE_DYNAMIC);
dynamicCommon.sendMsg(content.getCreateUser()); dynamicCommon.sendMsg(content.getCreateUser());
return quantity; return quantity;
} }
@ -99,5 +106,15 @@ public class DynamicLikeCmdExe {
return dynamicLikeService.exist(cmd.getDynamicId(), cmd.getReqUserId()); return dynamicLikeService.exist(cmd.getDynamicId(), cmd.getReqUserId());
} }
private void saveDynamicMessage(DynamicLikeCmd cmd, DynamicContent content, DynamicMessageEnum type) {
DynamicMessage message = new DynamicMessage();
message.setId(IdWorkerUtils.getId());
message.setDynamicContentId(cmd.getDynamicId());
message.setType(type.name());
message.setToUserId(content.getCreateUser());
message.setCreateTime(TimestampUtils.now());
message.setCreateUser(cmd.getReqUserId());
dynamicMessageService.save(message);
}
} }

View File

@ -85,7 +85,7 @@ public class DynamicMessageQryExe {
} }
private PageResult<DynamicMessage> getMessages(DynamicLimitCmd cmd) { private PageResult<DynamicMessage> getMessages(DynamicLimitCmd cmd) {
return dynamicMessageService.pageByTimeDesc(cmd.getPageReq(), cmd.getReqUserId()); return dynamicMessageService.pageByTimeDesc(cmd.getPageReq(), cmd.getReqUserId(), cmd.getDynamicMessageEnums());
} }
private Set<Long> getUserIds(PageResult<DynamicMessage> messages) { private Set<Long> getUserIds(PageResult<DynamicMessage> messages) {

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.red.circle.common.business.core.enums.GameStateEnum; import com.red.circle.common.business.core.enums.GameStateEnum;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.enums.DynamicMessageEnum;
import com.red.circle.component.redis.service.RedisService; import com.red.circle.component.redis.service.RedisService;
import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient;
import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd;
@ -43,6 +44,8 @@ import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManager
import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService; import com.red.circle.other.infra.database.mongo.service.sys.ActivityConfigService;
import com.red.circle.other.infra.database.mongo.service.user.count.UserGuardCountService; import com.red.circle.other.infra.database.mongo.service.user.count.UserGuardCountService;
import com.red.circle.other.infra.database.mongo.service.user.count.WeekFriendshipCardCountService; import com.red.circle.other.infra.database.mongo.service.user.count.WeekFriendshipCardCountService;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent;
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage;
import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkIntegralRecord; import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkIntegralRecord;
import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkRecord; import com.red.circle.other.infra.database.rds.entity.game.GameRoomPkRecord;
import com.red.circle.other.infra.database.rds.entity.user.user.ConfessionChance; import com.red.circle.other.infra.database.rds.entity.user.user.ConfessionChance;
@ -52,6 +55,7 @@ import com.red.circle.other.infra.database.rds.entity.user.user.CpValue;
import com.red.circle.other.infra.database.rds.entity.user.user.FriendshipCard; import com.red.circle.other.infra.database.rds.entity.user.user.FriendshipCard;
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.DynamicGiftService; import com.red.circle.other.infra.database.rds.service.dynamic.DynamicGiftService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageService;
import com.red.circle.other.infra.database.rds.service.game.GameRoomPkIntegralRecordService; import com.red.circle.other.infra.database.rds.service.game.GameRoomPkIntegralRecordService;
import com.red.circle.other.infra.database.rds.service.game.GameRoomPkRecordService; import com.red.circle.other.infra.database.rds.service.game.GameRoomPkRecordService;
import com.red.circle.other.infra.database.rds.service.live.RoomContributionBalanceService; import com.red.circle.other.infra.database.rds.service.live.RoomContributionBalanceService;
@ -135,6 +139,7 @@ public class GiftCountStrategy implements GiftStrategy {
private final RedisService redisService; private final RedisService redisService;
private final DynamicContentService dynamicContentService; private final DynamicContentService dynamicContentService;
private final DynamicGiftService dynamicGiftService; private final DynamicGiftService dynamicGiftService;
private final DynamicMessageService dynamicMessageService;
private static final List<String> inRegionCodes = List.of("IN", "PK", "BD"); private static final List<String> inRegionCodes = List.of("IN", "PK", "BD");
private final UserRegionCacheService userRegionCacheService; private final UserRegionCacheService userRegionCacheService;
@ -729,7 +734,7 @@ public class GiftCountStrategy implements GiftStrategy {
} }
// 验证动态是否存在 // 验证动态是否存在
com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent dynamicContent = DynamicContent dynamicContent =
dynamicContentService.getById(runningWater.getDynamicContentId()); dynamicContentService.getById(runningWater.getDynamicContentId());
if (dynamicContent == null || Boolean.TRUE.equals(dynamicContent.getDel())) { if (dynamicContent == null || Boolean.TRUE.equals(dynamicContent.getDel())) {
@ -757,6 +762,13 @@ public class GiftCountStrategy implements GiftStrategy {
giftValue.getUnitPrice() giftValue.getUnitPrice()
); );
dynamicMessageService.save(
runningWater.getGiftId() + " * " + giftValue.getQuantity(),
Long.parseLong(runningWater.getDynamicContentId()),
dynamicContent.getCreateUser(),
DynamicMessageEnum.DYNAMIC_GIFT
);
} catch (Exception e) { } catch (Exception e) {
log.error("处理动态礼物失败", e); log.error("处理动态礼物失败", e);
} }

View File

@ -2,9 +2,12 @@ package com.red.circle.other.app.dto.cmd.dynamic;
import com.red.circle.common.business.dto.PageReq; import com.red.circle.common.business.dto.PageReq;
import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.enums.DynamicMessageEnum;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.List;
/** /**
* 动态-内容分页. * 动态-内容分页.
* *
@ -20,4 +23,6 @@ public class DynamicLimitCmd extends AppExtCommand {
*/ */
private PageReq pageReq; private PageReq pageReq;
private List<DynamicMessageEnum> dynamicMessageEnums;
} }

View File

@ -39,6 +39,12 @@ public class DynamicMessage extends TimestampBaseEntity {
@TableField("dynamic_content_id") @TableField("dynamic_content_id")
private Long dynamicContentId; private Long dynamicContentId;
/**
* 动态评论ID
*/
@TableField("dynamic_comment_id")
private Long dynamicCommentId;
/** /**
* 内容. * 内容.
*/ */

View File

@ -46,7 +46,7 @@ public interface DynamicMessageService extends BaseService<DynamicMessage> {
* @param pageNumber 第几页 * @param pageNumber 第几页
* @param toUserId 被评价人或点赞ID * @param toUserId 被评价人或点赞ID
*/ */
PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId); PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId, List<DynamicMessageEnum> dynamicMessageEnums);
/** /**
* 我的消息列表统计 * 我的消息列表统计

View File

@ -11,12 +11,8 @@ import com.red.circle.other.infra.database.rds.service.dynamic.DynamicMessageSer
import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.collection.CollectionUtils;
import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.sequence.IdWorkerUtils; import com.red.circle.tool.core.sequence.IdWorkerUtils;
import java.util.Collection;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -93,11 +89,13 @@ public class DynamicMessageServiceImpl extends
} }
@Override @Override
public PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId) { public PageResult<DynamicMessage> pageByTimeDesc(PageQuery pageQuery, Long toUserId, List<DynamicMessageEnum> dynamicMessageEnums) {
return query() return query()
.eq(DynamicMessage::getToUserId, toUserId) .eq(DynamicMessage::getToUserId, toUserId)
.eq(DynamicMessage::getDel, Boolean.FALSE) .eq(DynamicMessage::getDel, Boolean.FALSE)
.in(dynamicMessageEnums != null, DynamicMessage::getType,
dynamicMessageEnums != null ? dynamicMessageEnums.stream().map(Enum::name).toList() : Collections.emptyList())
.orderByDesc(DynamicMessage::getCreateTime) .orderByDesc(DynamicMessage::getCreateTime)
.page(pageQuery); .page(pageQuery);
} }