房间主题问题处理
This commit is contained in:
parent
2b520516b7
commit
ffd86653de
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -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<UserUsePropsDTO> 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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user