package com.red.circle.other.app.inner.service.user.user.impl;

import com.red.circle.other.domain.gateway.user.ability.UserRelationsCalculatorGateway;
import com.red.circle.other.infra.database.rds.service.user.user.UserRelationshipCounterService;
import com.red.circle.other.app.inner.convertor.user.UserRelationsCalculatorInnerConvertor;
import com.red.circle.other.inner.model.cmd.user.UserRelationsCalculatorCmd;
import com.red.circle.other.app.inner.service.user.user.UserRelationCalculatorClientService;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户关系计算.
 *
 * @author pengliang on 2023/10/17
 */
@Service
@RequiredArgsConstructor
public class UserRelationCalculatorClientServiceImpl implements
    UserRelationCalculatorClientService {

  private final UserRelationsCalculatorGateway userRelationsCalculatorGateway;
  private final UserRelationshipCounterService userRelationshipCounterService;
  private final UserRelationsCalculatorInnerConvertor userRelationsCalculatorInnerConvertor;

  @Override
  public void calculator(UserRelationsCalculatorCmd cmd) {
    userRelationsCalculatorGateway.process(
        userRelationsCalculatorInnerConvertor.toUserRelationsCalculator(cmd)
    );
  }

  @Override
  public Map<Long, Long> mapFansNumberByUserId(Set<Long> userIds) {
    return userRelationshipCounterService.mapFansNumberByUserId(userIds);
  }
}
