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());