佩戴道具缓存处理

This commit is contained in:
tianfeng 2025-11-20 18:12:30 +08:00
parent 6574bafbd1
commit 3c0b4f5958

View File

@ -5,6 +5,7 @@ import com.mongodb.BasicDBObject;
import com.red.circle.other.infra.database.mongo.entity.user.profile.UserRunProfile;
import com.red.circle.other.infra.database.mongo.entity.user.profile.UserSpecialId;
import com.red.circle.other.infra.database.mongo.service.user.profile.UserRunProfileService;
import com.red.circle.other.inner.enums.material.BadgeConfigTypeEnum;
import com.red.circle.other.inner.model.dto.material.UseBadgeDTO;
import com.red.circle.other.inner.model.dto.material.UsePropsDTO;
import com.red.circle.tool.core.collection.CollectionUtils;
@ -320,7 +321,9 @@ public class UserRunProfileServiceImpl implements UserRunProfileService {
mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(id)),
new Update()
.set("updateTime", TimestampUtils.now())
.set("wearBadge", filterBadgeNotAvailable(wearBadges)),
.set("wearBadge", filterBadgeNotAvailable(wearBadges))
.set("wearHonor", filterHonorNotAvailable(wearBadges))
,
UserRunProfile.class);
}
@ -360,12 +363,24 @@ public class UserRunProfileServiceImpl implements UserRunProfileService {
private List<UseBadgeDTO> filterBadgeNotAvailable(List<UseBadgeDTO> wearBadge) {
if (CollectionUtils.isNotEmpty(wearBadge)) {
return wearBadge.stream().filter(badge -> checkAvailable(badge.getExpireTime()))
return wearBadge.stream()
.filter(badge -> !BadgeConfigTypeEnum.isHonorType(badge.getType()))
.filter(badge -> checkAvailable(badge.getExpireTime()))
.collect(Collectors.toList());
}
return wearBadge;
}
private List<UseBadgeDTO> filterHonorNotAvailable(List<UseBadgeDTO> wearBadge) {
if (CollectionUtils.isNotEmpty(wearBadge)) {
return wearBadge.stream()
.filter(badge -> BadgeConfigTypeEnum.isHonorType(badge.getType()))
.filter(badge -> checkAvailable(badge.getExpireTime()))
.collect(Collectors.toList());
}
return wearBadge;
}
@Override
public UserRunProfile getById(Long id) {
return mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), UserRunProfile.class);