diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/OtherErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/OtherErrorCode.java index b2d6fb2d..9aae9f20 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/OtherErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/OtherErrorCode.java @@ -211,6 +211,11 @@ public enum OtherErrorCode implements IResponseErrorCode { SIGN_IN_OPERATION_TOO_FREQUENT(3286, "Sign-in operation too frequent, please try again later"), CONSECUTIVE_REWARD(3287, "Consecutive Check-in Reward!"), + + /** + * 请先取消cp关系 + */ + CANCEL_CP_RELATION_FIRST(3288, "Please cancel the cp relationship first"), ; private final int code; 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 cae0df52..64aabb40 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 @@ -10,14 +10,19 @@ import com.red.circle.other.infra.database.mongo.entity.live.RoomUserBlacklist; import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService; import com.red.circle.other.infra.database.mongo.service.live.RoomUserBlacklistService; import com.red.circle.other.infra.database.rds.entity.user.user.BaseInfo; +import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; import com.red.circle.other.infra.database.rds.service.user.user.BaseInfoService; +import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService; 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.inner.asserts.OtherErrorCode; import com.red.circle.other.inner.enums.config.EnumConfigKey; import com.red.circle.other.inner.enums.live.RoomUserRolesEnum; import com.red.circle.tool.core.date.TimestampUtils; import com.red.circle.tool.core.text.StringUtils; import com.red.circle.other.inner.asserts.user.UserErrorCode; + +import java.util.List; import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -37,6 +42,7 @@ public class UserShieldBlackAddCmdExe { private final RoomUserBlacklistService roomUserBlacklistService; private final RoomProfileManagerService roomProfileManagerService; private final RelationshipFriendService relationshipFriendService; + private final CpRelationshipService cpRelationshipService; public void execute(UserShieldBlackUserCmd cmd) { @@ -47,6 +53,13 @@ public class UserShieldBlackAddCmdExe { StringUtils.isNotBlank(superAdminIds) && superAdminIds .contains(String.valueOf(cmd.getShieldUserId()))); + List cpRelationshipList = cpRelationshipService.getByUserId(cmd.requiredReqUserId()); + List dismissing = cpRelationshipService.getDismissingByUserId(cmd.requiredReqUserId()); + cpRelationshipList.addAll(dismissing); + + List cpUserIdList = cpRelationshipList.stream().map(CpRelationship::getCpUserId).toList(); + ResponseAssert.isFalse(OtherErrorCode.CANCEL_CP_RELATION_FIRST, cpUserIdList.contains(cmd.getShieldUserId())); + // 拉黑用户 shieldBlackService.saveShieldBlack(cmd.requiredReqUserId() , cmd.getShieldUserId());