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

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.game.GameEggClientService;
import com.red.circle.other.inner.endpoint.game.api.GameEggClientApi;
import com.red.circle.other.inner.model.cmd.game.GameEggConfigCmd;
import com.red.circle.other.inner.model.dto.game.GameEggStockConfigDTO;
import java.util.List;
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 lisizhe on 2023/11/10
 */
@Validated
@RestController
@RequestMapping(value = GameEggClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GameEggClientEndpoint implements GameEggClientApi {

  private final GameEggClientService gameEggClientService;


  @Override
  public ResultResponse<List<GameEggStockConfigDTO>> listConfig(String sysOrigin) {
    return ResultResponse.success(gameEggClientService.listConfig(sysOrigin));
  }

  @Override
  public ResultResponse<Void> updateConfig(GameEggConfigCmd param) {
    gameEggClientService.updateConfig(param);
    return ResultResponse.success();
  }

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

  @Override
  public ResultResponse<String> getPrizePool(String sysOrigin) {
    return ResultResponse.success(gameEggClientService.getPrizePool(sysOrigin));
  }

  @Override
  public ResultResponse<String> getExtractRatio(String sysOrigin) {
    return ResultResponse.success(gameEggClientService.getExtractRatio(sysOrigin));
  }

  @Override
  public ResultResponse<Void> setExtractRatio(String sysOrigin, String ratio) {
    gameEggClientService.setExtractRatio(sysOrigin, ratio);
    return ResultResponse.success();
  }
}
