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


import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.team.UserHistoryIdentityClientService;
import com.red.circle.other.inner.endpoint.team.target.api.UserHistoryIdentityClientApi;
import com.red.circle.other.inner.model.dto.agency.agency.UserHistoryIdentityDTO;
import java.util.List;
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/8/19
 */
@Validated
@RestController
@RequestMapping(value = UserHistoryIdentityClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserHistoryIdentityEndpoint implements UserHistoryIdentityClientApi {

  private final UserHistoryIdentityClientService historyIdentityClientService;


  @Override
  public ResultResponse<List<String>> getLabels(Long userId) {
    return ResultResponse.success(historyIdentityClientService.getLabels(userId));
  }

  @Override
  public ResultResponse<List<String>> getUserLabels(UserHistoryIdentityDTO identity) {
    return ResultResponse.success(historyIdentityClientService.getUserLabels(identity));
  }


  @Override
  public ResultResponse<Map<Long, UserHistoryIdentityDTO>> mapByIds(Set<Long> userIds) {
    return ResultResponse.success(historyIdentityClientService.mapByIds(userIds));
  }


  @Override
  public ResultResponse<Void> saveHost(Long userId) {
    historyIdentityClientService.saveHost(userId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> saveBd(Long userId) {
    historyIdentityClientService.saveBd(userId);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> saveManager(Long userId) {
    historyIdentityClientService.saveManager(userId);
    return ResultResponse.success();
  }
}
