cp空间列表增加cp等级相关字段

(cherry picked from commit 70e4e07a758d774da91fd0107e03747e4c83e701)
This commit is contained in:
tianfeng 2026-04-27 11:56:53 +08:00
parent 1303323df0
commit e4c8f7f3fe
3 changed files with 67 additions and 24 deletions

View File

@ -4,27 +4,24 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.mq.business.model.event.task.TaskApprovalEvent; import com.red.circle.mq.business.model.event.task.TaskApprovalEvent;
import com.red.circle.mq.rocket.business.producer.TaskMqMessage; import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
import com.red.circle.other.infra.database.rds.service.user.user.CpValueService;
import com.red.circle.tool.core.date.DateUtils;
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO; import com.red.circle.other.app.dto.clientobject.user.relation.cp.CpPairUserProfileCO;
import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.infra.database.cache.service.cp.CpRelationshipCacheService;
import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship;
import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService; import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService;
import com.red.circle.other.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.other.inner.model.dto.user.CpSimpleUserProfileCO;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.time.ZoneId;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
/** /**
* 用户cp对查询. * 用户cp对查询.
* *
@ -37,7 +34,7 @@ public class UserCpPairUserProfileQryExe {
private final CpRelationshipService cpRelationshipService; private final CpRelationshipService cpRelationshipService;
private final UserProfileGateway userProfileGateway; private final UserProfileGateway userProfileGateway;
private final UserProfileAppConvertor userProfileAppConvertor; private final UserProfileAppConvertor userProfileAppConvertor;
private final CpValueService cpValueService; private final CpRelationshipCacheService cpRelationshipCacheService;
private final TaskMqMessage taskMqMessage; private final TaskMqMessage taskMqMessage;
public List<CpPairUserProfileCO> execute(AppExtCommand cmd) { public List<CpPairUserProfileCO> execute(AppExtCommand cmd) {
@ -45,27 +42,41 @@ public class UserCpPairUserProfileQryExe {
UserProfile meUser = userProfileGateway.getByUserId(cmd.requiredReqUserId()); UserProfile meUser = userProfileGateway.getByUserId(cmd.requiredReqUserId());
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, meUser); ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, meUser);
List<CpRelationship> cpRelationshipList = cpRelationshipService.getByUserId(cmd.requiredReqUserId()); List<CpSimpleUserProfileCO> cpList = cpRelationshipCacheService.getUserCpList(cmd.requiredReqUserId());
List<CpRelationship> dismissing = cpRelationshipService.getDismissingByUserId(cmd.requiredReqUserId()); if (cpList.isEmpty()) {
cpRelationshipList.addAll(dismissing);
if (cpRelationshipList.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
return cpRelationshipList.stream() List<CpRelationship> dismissing = cpRelationshipService.getDismissingByUserId(cmd.requiredReqUserId());
.map(cpRelationship -> new CpPairUserProfileCO()
.setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser))) UserProfileDTO meUserProfileDTO = userProfileAppConvertor.toSimpleUserProfileDTO(meUser);
.setCpUserProfile(getUserProfile(cpRelationship.getCpUserId()))
.setStatus(cpRelationship.getStatus()) return cpList.stream()
.setCpValue(cpValueService.getCpVal(cpRelationship.getCpValId())) .map(cp -> {
.setDays(DateUtils.toDurationDays(cpRelationship.getCreateTime(), DateUtils.now())) String status = dismissing.stream()
.setFirstDay(cpRelationship.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString())) .anyMatch(d -> d.getCpUserId().equals(cp.getCpUserId())) ? "DISMISSING" : "NORMAL";
.sorted(Comparator.comparing(CpPairUserProfileCO::getCpValue).reversed()) return new CpPairUserProfileCO()
.toList(); .setMeUserProfile(meUserProfileDTO)
.setCpUserProfile(getUserProfile(cp.getCpUserId()))
.setStatus(status)
.setCpValue(cp.getCpValue())
.setDays(cp.getDays())
.setFirstDay(cp.getFirstDay())
.setCpLevel(cp.getCpLevel())
.setNextLevelExp(cp.getNextLevelExp())
.setLoveHeartLevel(cp.getLoveHeartLevel())
.setMicEffectLevel(cp.getMicEffectLevel())
.setProfileCardLevel(cp.getProfileCardLevel())
.setGiftWindowLevel(cp.getGiftWindowLevel())
.setHasNonMicEffect(cp.getHasNonMicEffect())
.setSelfRing(cp.getSelfRing());
})
.sorted(Comparator.comparing(CpPairUserProfileCO::getCpValue).reversed())
.toList();
} }
private UserProfileDTO getUserProfile(Long cpUserId) { private UserProfileDTO getUserProfile(Long cpUserId) {
return userProfileAppConvertor.toUserProfileDTO(userProfileGateway return userProfileAppConvertor.toSimpleUserProfileDTO(userProfileGateway
.getByUserId(cpUserId)); .getByUserId(cpUserId));
} }
} }

View File

@ -19,7 +19,10 @@ import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
/** /**
* @author pengliang on 2023/5/22 * @author pengliang on 2023/5/22
@ -27,10 +30,12 @@ import org.mapstruct.Mapper;
@Mapper(componentModel = ConvertorModel.SPRING) @Mapper(componentModel = ConvertorModel.SPRING)
public interface UserProfileAppConvertor { public interface UserProfileAppConvertor {
@Named("toUserProfileDTO")
UserProfileDTO toUserProfileDTO(UserProfile userProfile); UserProfileDTO toUserProfileDTO(UserProfile userProfile);
Map<Long, UserProfileDTO> toMapUserProfileDTO(Map<Long, UserProfile> userProfileMap); Map<Long, UserProfileDTO> toMapUserProfileDTO(Map<Long, UserProfile> userProfileMap);
@IterableMapping(qualifiedByName = "toUserProfileDTO")
List<UserProfileDTO> toListUserProfileDTO(List<UserProfile> userProfiles); List<UserProfileDTO> toListUserProfileDTO(List<UserProfile> userProfiles);
default LoginLoggerEvent toLoginLoggerEventRegister(CreateAccountCmd cmd) { default LoginLoggerEvent toLoginLoggerEventRegister(CreateAccountCmd cmd) {
@ -65,6 +70,17 @@ public interface UserProfileAppConvertor {
List<BadgeConfigDetailsDTO> toListBadgeConfigDetailsDTO(List<UserUseBadgeDTO> userUseBadges); List<BadgeConfigDetailsDTO> toListBadgeConfigDetailsDTO(List<UserUseBadgeDTO> userUseBadges);
@Mapping(target = "cpList", ignore = true)
@Mapping(target = "backgroundPhotos", ignore = true)
@Mapping(target = "personalPhotos", ignore = true)
@Mapping(target = "useProps", ignore = true)
@Mapping(target = "wearBadge", ignore = true)
@Mapping(target = "wearHonor", ignore = true)
@Mapping(target = "wearRide", ignore = true)
@Mapping(target = "wearAvatar", ignore = true)
@Mapping(target = "ownSpecialId", ignore = true)
UserProfileDTO toSimpleUserProfileDTO(UserProfile userProfile);
/** /**
* 将图片URL列表转为PhotoItem列表 * 将图片URL列表转为PhotoItem列表
*/ */

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.framework.dto.ClientObject; import com.red.circle.framework.dto.ClientObject;
import com.red.circle.other.inner.model.dto.user.CpRingDTO;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO; import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -54,5 +55,20 @@ public class CpPairUserProfileCO extends ClientObject {
*/ */
private String firstDay; private String firstDay;
private Integer cpLevel;
private Long nextLevelExp;
private Integer loveHeartLevel;
private Integer micEffectLevel;
private Integer profileCardLevel;
private Integer giftWindowLevel;
private Boolean hasNonMicEffect;
private CpRingDTO selfRing;
} }