From ffd86653de026bf667e339b203a8154efcddf238 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 20 Nov 2025 17:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E4=B8=BB=E9=A2=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/RoomThemeSwitchUseCmdExe.java | 19 ++++---- .../room/RoomViolationAdjustCmdExe.java | 44 ++++++++++++++++--- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomThemeSwitchUseCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomThemeSwitchUseCmdExe.java index aa48a6f4..c4ebfd0f 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomThemeSwitchUseCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/room/RoomThemeSwitchUseCmdExe.java @@ -1,5 +1,6 @@ package com.red.circle.other.app.command.room; +import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.other.app.dto.cmd.room.SwitchUseThemeCmd; @@ -39,21 +40,21 @@ public class RoomThemeSwitchUseCmdExe { private final RoomThemeUserCustomizeService roomThemeUserCustomizeService; public void execute(SwitchUseThemeCmd cmd) { - RoomProfile roomProfile = roomProfileManagerService.getProfileByUserId( - cmd.requiredReqUserId()); + Long reqUserId = cmd.getReqUserId(); + RoomProfile roomProfile = roomProfileManagerService.getProfileByUserId(reqUserId); ResponseAssert.notNull(RoomErrorCode.ROOM_NOT_EXISTS, roomProfile); ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, cmd.reqIsSelf(roomProfile.getUserId())); - userProfileGateway.removeCacheAll(cmd.requiredReqUserId()); + userProfileGateway.removeCacheAll(reqUserId); if (Objects.equals(cmd.getUnload(), Boolean.TRUE)) { ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE, - roomThemeUserBackpackService.cleanUseTheme(cmd.requiredReqUserId())); + roomThemeUserBackpackService.cleanUseTheme(reqUserId)); return; } RoomThemeUserBackpack backpack = roomThemeUserBackpackService.getNotExpireTimeByUserAndThemeId( - cmd.requiredReqUserId(), cmd.getThemeId()); + reqUserId, cmd.getThemeId()); // 免费 if (Objects.isNull(backpack)) { @@ -69,7 +70,7 @@ public class RoomThemeSwitchUseCmdExe { ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_MAPPING_INFO, sourceRecord); ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE, - roomThemeUserBackpackService.switchUseTheme(cmd.requiredReqUserId(), + roomThemeUserBackpackService.switchUseTheme(reqUserId, cmd.getThemeId(), Boolean.TRUE)); return; @@ -82,7 +83,7 @@ public class RoomThemeSwitchUseCmdExe { ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE, roomThemeUserBackpackService.switchUseTheme - (cmd.requiredReqUserId(), cmd.getThemeId(), Boolean.FALSE)); + (reqUserId, cmd.getThemeId(), Boolean.FALSE)); return; } @@ -94,7 +95,7 @@ public class RoomThemeSwitchUseCmdExe { ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE, roomThemeUserBackpackService.switchUseTheme - (cmd.requiredReqUserId(), cmd.getThemeId(), Boolean.FALSE)); + (reqUserId, cmd.getThemeId(), Boolean.FALSE)); } } @@ -103,7 +104,7 @@ public class RoomThemeSwitchUseCmdExe { } private PropsCommodityStore getThemeStoreBySourceId(SwitchUseThemeCmd cmd) { - return propsCommodityStoreService.getBySourceId(cmd.requireReqSysOriginEnum(), cmd.getThemeId(), + return propsCommodityStoreService.getBySourceId(SysOriginPlatformEnum.LIKEI, cmd.getThemeId(), PropsCommodityType.THEME.name()); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java index b56fc39c..1fabca28 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/violation/room/RoomViolationAdjustCmdExe.java @@ -6,11 +6,13 @@ import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExt import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.dto.cmd.room.SwitchUseThemeCmd; import com.red.circle.other.app.dto.cmd.violation.RoomViolationHandleCmd; import com.red.circle.other.app.dto.clientobject.violation.ViolationHandleResultCO; import com.red.circle.other.app.enums.violation.OperationTypeEnum; import com.red.circle.other.app.enums.violation.TargetTypeEnum; import com.red.circle.other.app.enums.violation.ViolationTypeEnum; +import com.red.circle.other.app.service.room.RoomThemeService; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway; import com.red.circle.other.domain.model.user.UserProfile; @@ -18,15 +20,23 @@ import com.red.circle.other.domain.violation.ViolationRecord; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; +import com.red.circle.other.infra.database.rds.entity.props.RoomThemeUserBackpack; +import com.red.circle.other.infra.database.rds.service.props.RoomThemeUserBackpackService; import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService; import com.red.circle.other.inner.asserts.RoomErrorCode; import com.red.circle.other.inner.enums.config.EnumConfigKey; +import com.red.circle.other.inner.enums.material.PropsCommodityType; +import com.red.circle.other.inner.model.dto.user.props.UserPropsResourcesDTO; +import com.red.circle.other.inner.model.dto.user.props.UserUsePropsDTO; +import com.red.circle.tool.core.collection.CollectionUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; /** * 房间违规调整命令执行器 @@ -42,6 +52,9 @@ public class RoomViolationAdjustCmdExe { private final OfficialNoticeClient officialNoticeClient; private final UserProfileGateway userProfileGateway; private final EnumConfigCacheService enumConfigCacheService; + private final RoomThemeService roomThemeService; + private final RoomThemeUserBackpackService roomThemeUserBackpackService; + // 默认内容配置 private static final String DEFAULT_ROOM_NOTICE = "Welcome to my room"; @@ -131,11 +144,32 @@ public class RoomViolationAdjustCmdExe { roomProfileManagerService.updateRoomDescByIds(java.util.Collections.singletonList(roomProfile.getId()), adjustedContent); } case ROOM_THEME -> { - adjustedContent = DEFAULT_THEME; - RoomProfile updateProfile = new RoomProfile(); - updateProfile.setId(roomProfile.getId()); -// updateProfile.setTheme(adjustedContent); - roomProfileManagerService.updateSelectiveProfile(updateProfile); + UserProfile userProfile = userProfileGateway.getByUserId(roomProfile.getUserId()); + + List usePropsEntities = userProfile.filterProps( + useProps -> Objects.equals(useProps.getPropsResources().getType(), + PropsCommodityType.THEME.name())); + + if (CollectionUtils.isEmpty(usePropsEntities)) { + return "null"; + } + + UserUsePropsDTO useProps = usePropsEntities.get(0); + UserPropsResourcesDTO resources = useProps.getPropsResources(); + adjustedContent = String.valueOf(resources.getId()); + + RoomThemeUserBackpack themeUserBackpack = roomThemeUserBackpackService.getById(resources.getId()); + if (themeUserBackpack == null) { + return "null"; + } + + roomThemeUserBackpackService.cleanUseTheme(userProfile.getId()); + userProfileGateway.removeCacheAll(userProfile.getId()); + + /*SwitchUseThemeCmd themeCmd = new SwitchUseThemeCmd(); + themeCmd.setThemeId(themeUserBackpack.getThemeId()); + themeCmd.setReqUserId(roomProfile.getUserId()); + roomThemeService.switchUseTheme(themeCmd);*/ } default -> adjustedContent = null; }