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 23e9c901..1698cdf4 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 @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; 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.mongo.entity.live.RoomProfile; import com.red.circle.other.infra.database.mongo.entity.live.RoomUserBlacklist; @@ -41,6 +43,7 @@ public class UserShieldBlackAddCmdExe { private final RelationshipFriendService relationshipFriendService; private final CpRelationshipService cpRelationshipService; private final UserSubscriptionService userSubscriptionService; + private final UserRelationsCalculatorGateway userRelationsCalculatorGateway; public void execute(UserShieldBlackUserCmd cmd) { @@ -62,11 +65,12 @@ public class UserShieldBlackAddCmdExe { shieldBlackService.saveShieldBlack(cmd.requiredReqUserId() , cmd.getShieldUserId()); - relationshipFriendService.removeFriend(cmd.requiredReqUserId(), cmd.getShieldUserId()); - relationshipFriendService.removeFriend(cmd.getShieldUserId(), cmd.requiredReqUserId()); - userSubscriptionService.remove(cmd.requiredReqUserId(), cmd.getShieldUserId()); - userSubscriptionService.remove(cmd.getShieldUserId(), cmd.requiredReqUserId()); + Long reqUserId = cmd.requiredReqUserId(); + Long shieldUserId = cmd.getShieldUserId(); + // 取消关注并删除好友 + cancelSubAndRmFriend(reqUserId, shieldUserId); + cancelSubAndRmFriend(shieldUserId, reqUserId); // 拉黑房间 BaseInfo beBlackUser = baseInfoService.getById(cmd.getShieldUserId()); @@ -89,4 +93,22 @@ 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) + ); + + relationshipFriendService.removeFriend(reqUserId, shieldUserId); + userRelationsCalculatorGateway.process(new UserRelationsCalculator() + .setUserId(reqUserId) + .setSubUserId(shieldUserId) + .setIncr(Boolean.FALSE) + .setType(UserRelationsCalculator.CounterEnum.FRIEND) + ); + } + }