关注用户增加黑名单限制
This commit is contained in:
parent
c953fd6869
commit
ff30192fe0
@ -224,6 +224,11 @@ public enum UserErrorCode implements IResponseErrorCode {
|
||||
// 用户已关注
|
||||
,USER_FOLLOWED(4075, "This user has followed"),
|
||||
|
||||
/**
|
||||
* 黑名单用户
|
||||
*/
|
||||
BLACK_USER(4076, "black user"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
@ -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());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user