房间主题问题处理
This commit is contained in:
parent
2b520516b7
commit
ffd86653de
@ -1,5 +1,6 @@
|
|||||||
package com.red.circle.other.app.command.room;
|
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.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
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.room.SwitchUseThemeCmd;
|
||||||
@ -39,21 +40,21 @@ public class RoomThemeSwitchUseCmdExe {
|
|||||||
private final RoomThemeUserCustomizeService roomThemeUserCustomizeService;
|
private final RoomThemeUserCustomizeService roomThemeUserCustomizeService;
|
||||||
|
|
||||||
public void execute(SwitchUseThemeCmd cmd) {
|
public void execute(SwitchUseThemeCmd cmd) {
|
||||||
RoomProfile roomProfile = roomProfileManagerService.getProfileByUserId(
|
Long reqUserId = cmd.getReqUserId();
|
||||||
cmd.requiredReqUserId());
|
RoomProfile roomProfile = roomProfileManagerService.getProfileByUserId(reqUserId);
|
||||||
ResponseAssert.notNull(RoomErrorCode.ROOM_NOT_EXISTS, roomProfile);
|
ResponseAssert.notNull(RoomErrorCode.ROOM_NOT_EXISTS, roomProfile);
|
||||||
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
|
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
|
||||||
cmd.reqIsSelf(roomProfile.getUserId()));
|
cmd.reqIsSelf(roomProfile.getUserId()));
|
||||||
|
|
||||||
userProfileGateway.removeCacheAll(cmd.requiredReqUserId());
|
userProfileGateway.removeCacheAll(reqUserId);
|
||||||
if (Objects.equals(cmd.getUnload(), Boolean.TRUE)) {
|
if (Objects.equals(cmd.getUnload(), Boolean.TRUE)) {
|
||||||
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
||||||
roomThemeUserBackpackService.cleanUseTheme(cmd.requiredReqUserId()));
|
roomThemeUserBackpackService.cleanUseTheme(reqUserId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomThemeUserBackpack backpack = roomThemeUserBackpackService.getNotExpireTimeByUserAndThemeId(
|
RoomThemeUserBackpack backpack = roomThemeUserBackpackService.getNotExpireTimeByUserAndThemeId(
|
||||||
cmd.requiredReqUserId(), cmd.getThemeId());
|
reqUserId, cmd.getThemeId());
|
||||||
|
|
||||||
// 免费
|
// 免费
|
||||||
if (Objects.isNull(backpack)) {
|
if (Objects.isNull(backpack)) {
|
||||||
@ -69,7 +70,7 @@ public class RoomThemeSwitchUseCmdExe {
|
|||||||
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_MAPPING_INFO, sourceRecord);
|
ResponseAssert.notNull(CommonErrorCode.NOT_FOUND_MAPPING_INFO, sourceRecord);
|
||||||
|
|
||||||
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
||||||
roomThemeUserBackpackService.switchUseTheme(cmd.requiredReqUserId(),
|
roomThemeUserBackpackService.switchUseTheme(reqUserId,
|
||||||
cmd.getThemeId(),
|
cmd.getThemeId(),
|
||||||
Boolean.TRUE));
|
Boolean.TRUE));
|
||||||
return;
|
return;
|
||||||
@ -82,7 +83,7 @@ public class RoomThemeSwitchUseCmdExe {
|
|||||||
|
|
||||||
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
||||||
roomThemeUserBackpackService.switchUseTheme
|
roomThemeUserBackpackService.switchUseTheme
|
||||||
(cmd.requiredReqUserId(), cmd.getThemeId(), Boolean.FALSE));
|
(reqUserId, cmd.getThemeId(), Boolean.FALSE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ public class RoomThemeSwitchUseCmdExe {
|
|||||||
|
|
||||||
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
||||||
roomThemeUserBackpackService.switchUseTheme
|
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) {
|
private PropsCommodityStore getThemeStoreBySourceId(SwitchUseThemeCmd cmd) {
|
||||||
return propsCommodityStoreService.getBySourceId(cmd.requireReqSysOriginEnum(), cmd.getThemeId(),
|
return propsCommodityStoreService.getBySourceId(SysOriginPlatformEnum.LIKEI, cmd.getThemeId(),
|
||||||
PropsCommodityType.THEME.name());
|
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.external.inner.model.enums.message.OfficialNoticeTypeEnum;
|
||||||
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.other.app.dto.cmd.room.SwitchUseThemeCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.violation.RoomViolationHandleCmd;
|
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.dto.clientobject.violation.ViolationHandleResultCO;
|
||||||
import com.red.circle.other.app.enums.violation.OperationTypeEnum;
|
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.TargetTypeEnum;
|
||||||
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
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.user.UserProfileGateway;
|
||||||
import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway;
|
import com.red.circle.other.domain.gateway.violation.ViolationRecordGateway;
|
||||||
import com.red.circle.other.domain.model.user.UserProfile;
|
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.cache.service.other.EnumConfigCacheService;
|
||||||
import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile;
|
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.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.infra.database.rds.service.sys.AdministratorAuthService;
|
||||||
import com.red.circle.other.inner.asserts.RoomErrorCode;
|
import com.red.circle.other.inner.asserts.RoomErrorCode;
|
||||||
import com.red.circle.other.inner.enums.config.EnumConfigKey;
|
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.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 房间违规调整命令执行器
|
* 房间违规调整命令执行器
|
||||||
@ -42,6 +52,9 @@ public class RoomViolationAdjustCmdExe {
|
|||||||
private final OfficialNoticeClient officialNoticeClient;
|
private final OfficialNoticeClient officialNoticeClient;
|
||||||
private final UserProfileGateway userProfileGateway;
|
private final UserProfileGateway userProfileGateway;
|
||||||
private final EnumConfigCacheService enumConfigCacheService;
|
private final EnumConfigCacheService enumConfigCacheService;
|
||||||
|
private final RoomThemeService roomThemeService;
|
||||||
|
private final RoomThemeUserBackpackService roomThemeUserBackpackService;
|
||||||
|
|
||||||
|
|
||||||
// 默认内容配置
|
// 默认内容配置
|
||||||
private static final String DEFAULT_ROOM_NOTICE = "Welcome to my room";
|
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);
|
roomProfileManagerService.updateRoomDescByIds(java.util.Collections.singletonList(roomProfile.getId()), adjustedContent);
|
||||||
}
|
}
|
||||||
case ROOM_THEME -> {
|
case ROOM_THEME -> {
|
||||||
adjustedContent = DEFAULT_THEME;
|
UserProfile userProfile = userProfileGateway.getByUserId(roomProfile.getUserId());
|
||||||
RoomProfile updateProfile = new RoomProfile();
|
|
||||||
updateProfile.setId(roomProfile.getId());
|
List<UserUsePropsDTO> usePropsEntities = userProfile.filterProps(
|
||||||
// updateProfile.setTheme(adjustedContent);
|
useProps -> Objects.equals(useProps.getPropsResources().getType(),
|
||||||
roomProfileManagerService.updateSelectiveProfile(updateProfile);
|
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;
|
default -> adjustedContent = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user