我的回复和我的礼物列表处理

This commit is contained in:
tianfeng 2026-02-02 17:10:17 +08:00
parent 8668ecaede
commit 4f2e9cbab9
5 changed files with 30 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicMessage;
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.DynamicMessageService;
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService;
import com.red.circle.other.inner.asserts.DynamicErrorCode;
import com.red.circle.other.inner.model.cmd.user.account.PunishmentAccountCmd;
import com.red.circle.tool.core.date.TimestampUtils;
@ -57,6 +58,7 @@ public class DynamicCommentCmdExe {
private final DynamicCommentService dynamicCommentService;
private final DynamicPopularService dynamicPopularService;
private final UserAccountCommon userAccountCommon;
private final DynamicPictureService dynamicPictureService;
public DynamicCommentListCO execute(DynamicCommentCmd cmd) {
ResponseAssert.isTrue(DynamicErrorCode.CURRENT_LEVEL_IS_TOO_LOW, commentLimit(cmd));
@ -79,7 +81,10 @@ public class DynamicCommentCmdExe {
dynamicPopularService.updateScore(dynamicContent.getId(), dynamicCacheService.getCommentScore(),
cmd.getReqSysOrigin().getOrigin(), dynamicContent.getRegion());
//评论不属于自己的动态发送消息
//content 设置为图片url
cmd.setContent(dynamicPictureService.getFirstNormalPic(dynamicContent.getId()));
if (Objects.isNull(cmd.getToUserId())) {
cmd.setToUserId(dynamicContent.getCreateUser());
saveDynamicMessage(cmd, DynamicMessageEnum.COMMENT_DYNAMIC);

View File

@ -36,6 +36,7 @@ public class DynamicMessageQryExe {
private final DynamicContentService dynamicContentService;
private final DynamicMessageService dynamicMessageService;
public PageResult<DynamicMessageListCO> execute(DynamicLimitCmd cmd) {
PageResult<DynamicMessage> messages = getMessages(cmd);

View File

@ -765,7 +765,7 @@ public class GiftCountStrategy implements GiftStrategy {
// 保存消息
DynamicMessage message = new DynamicMessage();
message.setContent(runningWater.getGiftId() + " * " + giftValue.getQuantity());
message.setContent(giftUrl);
message.setDynamicContentId(Long.parseLong(runningWater.getDynamicContentId()));
message.setToUserId( dynamicContent.getCreateUser());
message.setCreateUser(runningWater.getUserId());

View File

@ -118,4 +118,12 @@ public interface DynamicPictureService extends BaseService<DynamicPicture> {
* @return ignore
*/
boolean existsEmptyOrViolation(Long dynamicId);
/**
* 获取第一张正常图片URL按sort从小到大violation=NORMAL
*
* @param dynamicId 动态id
* @return 图片URL如果没有正常图片则返回null
*/
String getFirstNormalPic(Long dynamicId);
}

View File

@ -3,6 +3,7 @@ package com.red.circle.other.infra.database.rds.service.dynamic.impl;
import com.google.common.collect.Maps;
import com.red.circle.common.business.enums.PhotoApprovalStatusEnum;
import com.red.circle.common.business.enums.ViolationEnum;
import com.red.circle.framework.mybatis.constant.PageConstant;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.other.infra.database.rds.dao.dynamic.DynamicPictureDAO;
@ -173,4 +174,17 @@ public class DynamicPictureServiceImpl extends
.findFirst().map(photoWall -> Boolean.TRUE).orElse(Boolean.FALSE);
}
@Override
public String getFirstNormalPic(Long dynamicId) {
DynamicPicture picture = query()
.select(DynamicPicture::getResourceUrl)
.eq(DynamicPicture::getDynamicId, dynamicId)
.eq(DynamicPicture::getViolation, ViolationEnum.NORMAL.name())
.orderByAsc(DynamicPicture::getSort)
.last(PageConstant.LIMIT_ONE)
.getOne();
return picture != null ? picture.getResourceUrl() : null;
}
}