From ff30192fe08a62d7dd0b7c7c650c681d61a173e3 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 19 Jan 2026 16:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E7=94=A8=E6=88=B7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=BB=91=E5=90=8D=E5=8D=95=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/inner/asserts/user/UserErrorCode.java | 5 +++++ .../UserSupportRelationFollowOrCancelCmdExe.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java index 5f25fae5..6f09188c 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java @@ -224,6 +224,11 @@ public enum UserErrorCode implements IResponseErrorCode { // 用户已关注 ,USER_FOLLOWED(4075, "This user has followed"), + /** + * 黑名单用户 + */ + BLACK_USER(4076, "black user"), + ; diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java index 47afea88..9eb451ba 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/UserSupportRelationFollowOrCancelCmdExe.java @@ -21,6 +21,7 @@ import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManager import com.red.circle.other.infra.database.mongo.service.live.RoomUserBlacklistService; import com.red.circle.other.infra.database.mongo.service.user.friend.FriendsApplyListService; import com.red.circle.other.infra.database.rds.entity.user.user.RelationshipFriend; +import com.red.circle.other.infra.database.rds.entity.user.user.ShieldBlack; import com.red.circle.other.infra.database.rds.service.user.user.RelationshipFriendService; import com.red.circle.other.infra.database.rds.service.user.user.ShieldBlackService; import com.red.circle.other.infra.database.rds.service.user.user.UserSubscriptionService; @@ -37,6 +38,7 @@ import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.Optional; /** * 用户关系订阅. @@ -63,11 +65,25 @@ public class UserSupportRelationFollowOrCancelCmdExe { // 不可操作自己 ResponseAssert.notEquals(UserErrorCode.NOT_OPERATION_ME, cmd.requiredReqUserId(), cmd.getUserId()); + + boolean blackUser1 = queryBlackUser(cmd.requiredReqUserId(), cmd.getUserId()); + boolean blackUser2 = queryBlackUser(cmd.getUserId(), cmd.requiredReqUserId()); + ResponseAssert.isFalse(UserErrorCode.BLACK_USER, blackUser1 || blackUser2); + return userSubscriptionService.checkSubscription(cmd.requiredReqUserId(), cmd.getUserId()) ? cancelSubscription(cmd) : subscription(cmd); } + private boolean queryBlackUser(Long reqUserId, Long userId) { + return Optional.ofNullable(shieldBlackService.query() + .select(ShieldBlack::getId) + .eq(ShieldBlack::getUserId, reqUserId) + .eq(ShieldBlack::getShieldUserId, userId) + .getOne() + ).map(shieldBlack -> Objects.nonNull(shieldBlack.getId())).orElse(Boolean.FALSE); + } + public Boolean follow(AppUserIdCmd cmd) { // 不可操作自己 ResponseAssert.notEquals(UserErrorCode.NOT_OPERATION_ME, cmd.requiredReqUserId(),cmd.getUserId());