打榜和周星排行榜隐身处理
This commit is contained in:
parent
aa50d842c6
commit
cc22708e70
@ -11,6 +11,7 @@ import com.red.circle.other.domain.enums.VipAbilityType;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.model.user.UserProfile;
|
||||
import com.red.circle.other.domain.ranking.RankingActivityType;
|
||||
import com.red.circle.other.infra.utils.UserIdEncryptUtils;
|
||||
import com.red.circle.other.domain.ranking.RankingCycleType;
|
||||
import com.red.circle.other.domain.ranking.RankingDimension;
|
||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||
@ -72,23 +73,23 @@ public class RankingListQryExe {
|
||||
cmd.getTopN()
|
||||
);
|
||||
|
||||
Set<Long> userIds = getUserIds(records);
|
||||
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
|
||||
userProfileGateway
|
||||
.mapByUserIds(getUserIds(records)));
|
||||
userProfileGateway.mapByUserIds(userIds));
|
||||
Set<Long> invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY);
|
||||
|
||||
// 转换为CO并设置排名
|
||||
List<RankingActivityRecordCO> rankingList = IntStream.range(0, records.size())
|
||||
.mapToObj(i -> {
|
||||
RankingActivityRecord record = records.get(i);
|
||||
RankingActivityRecordCO co = convertor.toRecordCO(record);
|
||||
co.setRank(i + 1); // 排名从1开始
|
||||
co.setRank(i + 1);
|
||||
|
||||
UserProfileDTO userProfileDTO = userProfileMap.get(record.getUserId());
|
||||
if (userProfileDTO != null) {
|
||||
boolean invisible = userProfileGateway.getUserVipAbility(
|
||||
record.getUserId(), VipAbilityType.MYSTERIOUS_INVISIBILITY);
|
||||
if (invisible) {
|
||||
if (invisibleUserIds.contains(record.getUserId())) {
|
||||
co.setUserId(null);
|
||||
co.setEncryptedId(UserIdEncryptUtils.encrypt(userProfileDTO.getId()));
|
||||
co.setAccount(null);
|
||||
co.setNickname("****");
|
||||
co.setAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfileDTO.getSysOriginChild()));
|
||||
@ -153,7 +154,10 @@ public class RankingListQryExe {
|
||||
|
||||
// 从排行榜列表中查找当前用户
|
||||
Optional<RankingActivityRecordCO> userInList = rankingList.stream()
|
||||
.filter(record -> cmd.getReqUserId().equals(record.getUserId()))
|
||||
.filter(record -> cmd.getReqUserId().equals(record.getUserId())
|
||||
|| (record.getUserId() == null
|
||||
&& record.getEncryptedId() != null
|
||||
&& cmd.getReqUserId().equals(UserIdEncryptUtils.decrypt(record.getEncryptedId()))))
|
||||
.findFirst();
|
||||
|
||||
if (userInList.isPresent()) {
|
||||
|
||||
@ -7,9 +7,13 @@ import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.activity.UserRankCO;
|
||||
import com.red.circle.other.app.dto.clientobject.activity.WeekStarGiftUserRankCO;
|
||||
import com.red.circle.other.app.dto.cmd.activity.WeekStarRankingQueryCmd;
|
||||
import com.red.circle.other.domain.enums.VipAbilityType;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||
import com.red.circle.other.infra.database.mongo.entity.activity.WeekStarGiftCount;
|
||||
import com.red.circle.other.infra.database.mongo.service.activity.WeekStarGiftCountService;
|
||||
import com.red.circle.other.infra.utils.UserIdEncryptUtils;
|
||||
import com.red.circle.other.inner.enums.config.EnumConfigKey;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.num.NumUtils;
|
||||
@ -33,6 +37,7 @@ public class WeekStarGiftRankingQueryExe {
|
||||
private final UserProfileGateway userProfileGateway;
|
||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||
private final WeekStarGiftCountService weekStarGiftCountService;
|
||||
private final EnumConfigCacheService enumConfigCacheService;
|
||||
|
||||
public WeekStarGiftUserRankCO execute(WeekStarRankingQueryCmd cmd) {
|
||||
WeekStarGiftUserRankCO result = new WeekStarGiftUserRankCO()
|
||||
@ -80,10 +85,11 @@ public class WeekStarGiftRankingQueryExe {
|
||||
|
||||
List<WeekStarGiftCount> weekStarGiftCounts = (List<WeekStarGiftCount>) pageResult.getRecords();
|
||||
|
||||
Set<Long> userIds = getUserIds(weekStarGiftCounts);
|
||||
Map<Long, UserProfileDTO> userProfileMap = userProfileAppConvertor.toMapUserProfileDTO(
|
||||
userProfileGateway
|
||||
.mapByUserIds(getUserIds(weekStarGiftCounts))
|
||||
userProfileGateway.mapByUserIds(userIds)
|
||||
);
|
||||
Set<Long> invisibleUserIds = userProfileGateway.filterUsersByVipAbility(userIds, VipAbilityType.MYSTERIOUS_INVISIBILITY);
|
||||
|
||||
List<UserRankCO> list = weekStarGiftCounts.stream()
|
||||
.map(item -> {
|
||||
@ -91,6 +97,18 @@ public class WeekStarGiftRankingQueryExe {
|
||||
if (Objects.isNull(userProfile)) {
|
||||
return null;
|
||||
}
|
||||
if (invisibleUserIds.contains(item.getUserId())) {
|
||||
return new UserRankCO()
|
||||
.setUserId(null)
|
||||
.setEncryptedId(UserIdEncryptUtils.encrypt(userProfile.getId()))
|
||||
.setAccount(null)
|
||||
.setUserAvatar(enumConfigCacheService.getValue(EnumConfigKey.USER_YINSHEN_COVER, userProfile.getSysOriginChild()))
|
||||
.setRank(item.getRank())
|
||||
.setUserNickname("****")
|
||||
.setQuantity(NumUtils.formatLong(item.getQuantity()))
|
||||
.setCountryCode(null)
|
||||
.setCountryName(null);
|
||||
}
|
||||
return new UserRankCO()
|
||||
.setUserId(userProfile.getId())
|
||||
.setAccount(userProfile.getAccount())
|
||||
|
||||
@ -20,6 +20,11 @@ public class RankingActivityRecordCO implements Serializable {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 加密后的用户ID(隐身用户使用,用于myRank匹配).
|
||||
*/
|
||||
private String encryptedId;
|
||||
|
||||
private String account;
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user