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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.sys.SysGameListConfigClientService;
import com.red.circle.other.inner.endpoint.sys.api.SysGameListConfigClientApi;
import com.red.circle.other.inner.model.cmd.game.GameEggQryCmd;
import com.red.circle.other.inner.model.cmd.sys.SysGameListConfigParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysGameListQryCmd;
import com.red.circle.other.inner.model.cmd.sys.SysGameMatchModelConfigBackQryCmd;
import com.red.circle.other.inner.model.dto.game.GameUserLotteryDetailsRecordDTO;
import com.red.circle.other.inner.model.dto.game.GameUserLotteryRecordDTO;
import com.red.circle.other.inner.model.dto.game.GameUserShardsExchangeRecordDTO;
import com.red.circle.other.inner.model.dto.sys.GameMatchModelConfigDTO;
import com.red.circle.other.inner.model.dto.sys.SysGameListConfigDTO;
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 zongpubin on 2023/10/31
 */
@Validated
@RestController
@RequestMapping(value = SysGameListConfigClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class SysGameListConfigClientEndpoint implements SysGameListConfigClientApi {

  private final SysGameListConfigClientService gameListConfigClientService;

  @Override
  public ResultResponse<PageResult<SysGameListConfigDTO>> pageQuery(SysGameListQryCmd query) {
    return ResultResponse.success(gameListConfigClientService.pageQuery(query));
  }

  @Override
  public ResultResponse<Void> saveOrUpdate(SysGameListConfigParamCmd param) {
    gameListConfigClientService.saveOrUpdate(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> delete(Long id, String sysOrigin) {
    gameListConfigClientService.delete(id, sysOrigin);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<List<GameMatchModelConfigDTO>> lisMatchConfig(
      SysGameMatchModelConfigBackQryCmd query) {
    return ResultResponse.success(gameListConfigClientService.lisMatchConfig(query));
  }

  @Override
  public ResultResponse<Void> addOrUpdateMatchConfig(GameMatchModelConfigDTO param) {
    gameListConfigClientService.addOrUpdateMatchConfig(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> removeMatchConfig(Long id) {
    gameListConfigClientService.removeMatchConfig(id);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<GameUserLotteryRecordDTO>> pageGameUserLotteryRecord(
      GameEggQryCmd query) {
    return ResultResponse.success(gameListConfigClientService.pageGameUserLotteryRecord(query));
  }


  @Override
  public ResultResponse<Map<Long, List<GameUserLotteryDetailsRecordDTO>>> mapByLotteryIds(
      Set<Long> lotteryIds) {
    return ResultResponse.success(gameListConfigClientService.mapByLotteryIds(lotteryIds));
  }


  @Override
  public ResultResponse<PageResult<GameUserShardsExchangeRecordDTO>> pageUserShardsExchange(
      GameEggQryCmd query) {
    return ResultResponse.success(gameListConfigClientService.pageUserShardsExchange(
        query));
  }


  @Override
  public ResultResponse<SysGameListConfigDTO> getByGameCode(String gameCode, String sysOrigin) {
    return ResultResponse.success(gameListConfigClientService.getByGameCode(gameCode, sysOrigin));
  }


  @Override
  public ResultResponse<Boolean> checkGameUnshelve(Set<Long> gameIds) {
    return ResultResponse.success(gameListConfigClientService.checkGameUnshelve(gameIds));
  }
}
