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.UserRegionConfigMapCmd;
import com.red.circle.other.inner.model.dto.user.SysExchangeGoldTipDTO;
import com.red.circle.other.inner.model.dto.user.reigon.HostApplyQuitTeamCheckDTO;
import com.red.circle.other.inner.model.dto.user.reigon.RegionConfigDTO;
import com.red.circle.other.inner.model.dto.user.reigon.SysRegionAssistProbabilityDTO;
import com.red.circle.other.inner.model.dto.user.reigon.UserRegionDTO;
import com.red.circle.other.app.inner.service.user.region.UserRegionClientService;
import com.red.circle.other.inner.endpoint.user.region.api.UserRegionClientApi;
import java.math.BigDecimal;
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/6/11
 */
@Validated
@RestController
@RequestMapping(value = UserRegionClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserRegionClientEndpoint implements UserRegionClientApi {

  private final UserRegionClientService userRegionClientService;

  @Override
  public ResultResponse<String> getRegionCode(Long userId) {
    return ResultResponse.success(userRegionClientService.getRegionCode(userId));
  }

  @Override
  public ResultResponse<Map<Long, String>> mapRegionCode(Set<Long> userIds) {
    return ResultResponse.success(userRegionClientService.mapRegionCode(userIds));
  }

  @Override
  public ResultResponse<String> getRegionId(Long userId) {
    return ResultResponse.success(userRegionClientService.getRegionId(userId));
  }

  @Override
  public ResultResponse<UserRegionDTO> getRegion(Long userId) {
    return ResultResponse.success(userRegionClientService.getRegion(userId));
  }

  @Override
  public ResultResponse<List<SysExchangeGoldTipDTO>> listRegionExchangeGoldTip(Long userId, Boolean isCoinSeller) {
    return ResultResponse.success(userRegionClientService.listRegionExchangeGoldTip(userId, isCoinSeller));
  }

  @Override
  public ResultResponse<List<SysExchangeGoldTipDTO>> listRegionExchangeDiamondGoldTip(Long userId) {
    return ResultResponse.success(userRegionClientService.listRegionExchangeDiamondGoldTip(userId));
  }

  @Override
  public ResultResponse<List<SysExchangeGoldTipDTO>> listRegionWithdrawTip(Long userId) {
    return ResultResponse.success(userRegionClientService.listRegionWithdrawTip(userId));
  }

  @Override
  public ResultResponse<RegionConfigDTO> getSysRegionConfigByUserId(Long userId) {
    return ResultResponse.success(userRegionClientService.getSysRegionConfigByUserId(userId));
  }

  @Override
  public ResultResponse<Boolean> checkEqRegion(Long userId, Long compareUserId) {
    return ResultResponse.success(userRegionClientService.checkEqRegion(userId, compareUserId));
  }

  @Override
  public ResultResponse<Boolean> checkBusinessRegion(Long userId, Long compareUserId) {
    return ResultResponse.success(
        userRegionClientService.checkBusinessRegion(userId, compareUserId));
  }

  @Override
  public ResultResponse<Boolean> checkBusinessRegionCode(String code, String compareCode) {
    return ResultResponse.success(
        userRegionClientService.checkBusinessRegionCode(code, compareCode));
  }

  @Override
  public ResultResponse<Boolean> checkOpenDailyAutoSalary(String regionId, String sysOrigin) {
    return ResultResponse.success(
        userRegionClientService.checkOpenDailyAutoSalary(regionId, sysOrigin));
  }

  @Override
  public ResultResponse<HostApplyQuitTeamCheckDTO> getHostApplyQuitTeamCheckByUserId(Long userId) {
    return ResultResponse.success(
        userRegionClientService.getHostApplyQuitTeamCheckByUserId(userId));
  }

  @Override
  public ResultResponse<HostApplyQuitTeamCheckDTO> getHostApplyQuitTeamCheckByRegionId(
      String regionId) {
    return ResultResponse.success(
        userRegionClientService.getHostApplyQuitTeamCheckByRegionId(regionId));
  }

  @Override
  public ResultResponse<SysRegionAssistProbabilityDTO> getAssistRoomContributionRatio(Long userId) {
    return ResultResponse.success(userRegionClientService.getAssistRoomContributionRatio(userId));
  }

  @Override
  public ResultResponse<BigDecimal> getResidueTargetExchangeRatio(String regionId) {
    return ResultResponse.success(userRegionClientService.getResidueTargetExchangeRatio(regionId));
  }

  @Override
  public ResultResponse<BigDecimal> getAssistGiftToOtherGoldRatio(String regionId) {
    return ResultResponse.success(userRegionClientService.getAssistGiftToOtherGoldRatio(regionId));
  }

  @Override
  public ResultResponse<BigDecimal> getAssistGiftToOwnGoldRatio(String regionId) {
    return ResultResponse.success(userRegionClientService.getAssistGiftToOwnGoldRatio(regionId));
  }


  @Override
  public ResultResponse<Map<Long, RegionConfigDTO>> mapUserRegionConfig(
      UserRegionConfigMapCmd cmd) {
    return ResultResponse.success(
        userRegionClientService.mapUserRegionConfig(cmd.getSysOrigin(), cmd.getUserIds()));
  }

  @Override
  public ResultResponse<List<RegionConfigDTO>> listSysRegionConfig(String sysOrigin) {
    return ResultResponse.success(
        userRegionClientService.listSysRegionConfig(sysOrigin));
  }

}
