package com.red.circle.other.app.inner.endpoint.user.user;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.UserRelationsCalculatorCmd;
import com.red.circle.other.app.inner.service.user.user.UserRelationCalculatorClientService;
import com.red.circle.other.inner.endpoint.user.user.api.UserRelationCalculatorClientApi;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户关系计算.
 *
 * @author pengliang on 2023/10/17
 */
@Validated
@RestController
@RequestMapping(value = UserRelationCalculatorClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserRelationCalculatorClientEndpoint implements UserRelationCalculatorClientApi {

  private final UserRelationCalculatorClientService userRelationCalculatorClientService;

  @Override
  public ResultResponse<Void> calculator(UserRelationsCalculatorCmd cmd) {
    userRelationCalculatorClientService.calculator(cmd);
    return ResultResponse.success();
  }

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

}
