From e4c8f7f3feb635c5f7517f2b2e294c53b79413b7 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 27 Apr 2026 11:56:53 +0800 Subject: [PATCH] =?UTF-8?q?cp=E7=A9=BA=E9=97=B4=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0cp=E7=AD=89=E7=BA=A7=E7=9B=B8=E5=85=B3=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 70e4e07a758d774da91fd0107e03747e4c83e701) --- .../query/UserCpPairUserProfileQryExe.java | 59 +++++++++++-------- .../user/UserProfileAppConvertor.java | 16 +++++ .../user/relation/cp/CpPairUserProfileCO.java | 16 +++++ 3 files changed, 67 insertions(+), 24 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserCpPairUserProfileQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserCpPairUserProfileQryExe.java index 9ac910b3..1b06a1e4 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserCpPairUserProfileQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/UserCpPairUserProfileQryExe.java @@ -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.mq.business.model.event.task.TaskApprovalEvent; 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.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.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.service.user.user.CpRelationshipService; 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 lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; -import java.time.ZoneId; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; -import com.red.circle.tool.core.date.LocalDateTimeUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; - /** * 用户cp对查询. * @@ -37,7 +34,7 @@ public class UserCpPairUserProfileQryExe { private final CpRelationshipService cpRelationshipService; private final UserProfileGateway userProfileGateway; private final UserProfileAppConvertor userProfileAppConvertor; - private final CpValueService cpValueService; + private final CpRelationshipCacheService cpRelationshipCacheService; private final TaskMqMessage taskMqMessage; public List execute(AppExtCommand cmd) { @@ -45,27 +42,41 @@ public class UserCpPairUserProfileQryExe { UserProfile meUser = userProfileGateway.getByUserId(cmd.requiredReqUserId()); ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, meUser); - List cpRelationshipList = cpRelationshipService.getByUserId(cmd.requiredReqUserId()); - List dismissing = cpRelationshipService.getDismissingByUserId(cmd.requiredReqUserId()); - cpRelationshipList.addAll(dismissing); - if (cpRelationshipList.isEmpty()) { + List cpList = cpRelationshipCacheService.getUserCpList(cmd.requiredReqUserId()); + if (cpList.isEmpty()) { return Collections.emptyList(); } - return cpRelationshipList.stream() - .map(cpRelationship -> new CpPairUserProfileCO() - .setMeUserProfile(userProfileAppConvertor.toUserProfileDTO((meUser))) - .setCpUserProfile(getUserProfile(cpRelationship.getCpUserId())) - .setStatus(cpRelationship.getStatus()) - .setCpValue(cpValueService.getCpVal(cpRelationship.getCpValId())) - .setDays(DateUtils.toDurationDays(cpRelationship.getCreateTime(), DateUtils.now())) - .setFirstDay(cpRelationship.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().toString())) - .sorted(Comparator.comparing(CpPairUserProfileCO::getCpValue).reversed()) - .toList(); + List dismissing = cpRelationshipService.getDismissingByUserId(cmd.requiredReqUserId()); + + UserProfileDTO meUserProfileDTO = userProfileAppConvertor.toSimpleUserProfileDTO(meUser); + + return cpList.stream() + .map(cp -> { + String status = dismissing.stream() + .anyMatch(d -> d.getCpUserId().equals(cp.getCpUserId())) ? "DISMISSING" : "NORMAL"; + return new CpPairUserProfileCO() + .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) { - return userProfileAppConvertor.toUserProfileDTO(userProfileGateway + return userProfileAppConvertor.toSimpleUserProfileDTO(userProfileGateway .getByUserId(cpUserId)); } } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/user/UserProfileAppConvertor.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/user/UserProfileAppConvertor.java index 38efd202..9f6a1fb8 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/user/UserProfileAppConvertor.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/convertor/user/UserProfileAppConvertor.java @@ -19,7 +19,10 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.mapstruct.IterableMapping; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Named; /** * @author pengliang on 2023/5/22 @@ -27,10 +30,12 @@ import org.mapstruct.Mapper; @Mapper(componentModel = ConvertorModel.SPRING) public interface UserProfileAppConvertor { + @Named("toUserProfileDTO") UserProfileDTO toUserProfileDTO(UserProfile userProfile); Map toMapUserProfileDTO(Map userProfileMap); + @IterableMapping(qualifiedByName = "toUserProfileDTO") List toListUserProfileDTO(List userProfiles); default LoginLoggerEvent toLoginLoggerEventRegister(CreateAccountCmd cmd) { @@ -65,6 +70,17 @@ public interface UserProfileAppConvertor { List toListBadgeConfigDetailsDTO(List 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列表 */ diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/user/relation/cp/CpPairUserProfileCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/user/relation/cp/CpPairUserProfileCO.java index c00b49d3..fa6ee204 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/user/relation/cp/CpPairUserProfileCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/user/relation/cp/CpPairUserProfileCO.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 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 lombok.Data; import lombok.EqualsAndHashCode; @@ -54,5 +55,20 @@ public class CpPairUserProfileCO extends ClientObject { */ 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; }