拉黑人数减少处理

This commit is contained in:
tianfeng 2026-01-19 16:42:15 +08:00
parent cb961a8edb
commit c953fd6869

View File

@ -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)
);
}
}