From 4f56f8e8bfdcf9896b715c0d0c874affe926d086 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 19 Jan 2026 17:42:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E9=BB=91=E9=80=BB=E8=BE=91=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/UserShieldBlackAddCmdExe.java | 35 +++++++++++-------- .../user/user/RelationshipFriendService.java | 5 +++ .../impl/RelationshipFriendServiceImpl.java | 10 ++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserShieldBlackAddCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserShieldBlackAddCmdExe.java index 1698cdf4..fd86c13b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserShieldBlackAddCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserShieldBlackAddCmdExe.java @@ -7,6 +7,7 @@ import com.red.circle.other.app.dto.cmd.user.user.UserShieldBlackUserCmd; import com.red.circle.other.domain.gateway.user.ability.UserRelationsCalculatorGateway; import com.red.circle.other.domain.model.user.ability.UserRelationsCalculator; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; +import com.red.circle.other.infra.database.cache.service.user.UserRelationshipCacheService; import com.red.circle.other.infra.database.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.entity.live.RoomUserBlacklist; import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; @@ -44,6 +45,7 @@ public class UserShieldBlackAddCmdExe { private final CpRelationshipService cpRelationshipService; private final UserSubscriptionService userSubscriptionService; private final UserRelationsCalculatorGateway userRelationsCalculatorGateway; + private final UserRelationshipCacheService userRelationshipCacheService; public void execute(UserShieldBlackUserCmd cmd) { @@ -94,21 +96,26 @@ public class UserShieldBlackAddCmdExe { } private void cancelSubAndRmFriend(Long reqUserId, Long shieldUserId) { - userSubscriptionService.remove(reqUserId, shieldUserId); - userRelationsCalculatorGateway.process(new UserRelationsCalculator() - .setUserId(reqUserId) - .setSubUserId(shieldUserId) - .setIncr(Boolean.FALSE) - .setType(UserRelationsCalculator.CounterEnum.SUBSCRIPTION) - ); + boolean removed = userSubscriptionService.remove(reqUserId, shieldUserId); + if (removed) { + userRelationsCalculatorGateway.process(new UserRelationsCalculator() + .setUserId(reqUserId) + .setSubUserId(shieldUserId) + .setIncr(Boolean.FALSE) + .setType(UserRelationsCalculator.CounterEnum.SUBSCRIPTION) + ); + } - relationshipFriendService.removeFriend(reqUserId, shieldUserId); - userRelationsCalculatorGateway.process(new UserRelationsCalculator() - .setUserId(reqUserId) - .setSubUserId(shieldUserId) - .setIncr(Boolean.FALSE) - .setType(UserRelationsCalculator.CounterEnum.FRIEND) - ); + boolean removedFriendId = relationshipFriendService.removeFriendId(reqUserId, shieldUserId); + if (removedFriendId) { + userRelationsCalculatorGateway.process(new UserRelationsCalculator() + .setUserId(reqUserId) + .setSubUserId(shieldUserId) + .setIncr(Boolean.FALSE) + .setType(UserRelationsCalculator.CounterEnum.FRIEND) + ); + } + userRelationshipCacheService.removeFriend(reqUserId, shieldUserId); } } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/RelationshipFriendService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/RelationshipFriendService.java index 9c173ce3..b9d5a0e9 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/RelationshipFriendService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/RelationshipFriendService.java @@ -50,6 +50,11 @@ public interface RelationshipFriendService extends BaseService Objects.nonNull(relationshipFriend.getId())).orElse(Boolean.FALSE); } + @Override + public boolean removeFriendId(Long userId, Long friendUserId) { + return delete() + .eq(RelationshipFriend::getUserId, userId) + .eq(RelationshipFriend::getFriendUserId, friendUserId) + .last(PageConstant.LIMIT_ONE) + .execute(); + } + + @Override public void removeFriend(Long userId, Long friendUserId) { delete()