package com.red.circle.console.adapter.app.game;

import com.red.circle.console.app.dto.clienobject.game.GameLuckyGiftCO;
import com.red.circle.console.app.service.app.game.GameLuckyGiftConfigService;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.game.GameLuckGiftProbabilityConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckGiftRuleConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckGiftStandardConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.LuckGiftGameCountQryCmd;
import com.red.circle.other.inner.model.cmd.game.LuckGiftGameQryCmd;
import com.red.circle.other.inner.model.dto.game.GameLuckyGiftCountDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyGiftProbabilityDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyGiftProbabilityInfoDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyGiftRuleConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyGiftStandardConfigDTO;
import com.red.circle.other.inner.model.dto.game.LuckyGiftStandardMapDTO;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 幸运礼物奖项配置 前端控制器.
 *
 * @author zongpubin on 2023-06-16 16:20
 */
@AllArgsConstructor
@RestController
@RequestMapping("/game/lucky-gift")
public class GameLuckyGiftConfigRestController extends BaseController {

  private final GameLuckyGiftConfigService gameLuckyGiftConfigService;

  /**
   * 查询抽奖记录.
   */
  @GetMapping("/page/game/record")
  public PageResult<GameLuckyGiftCO> pageLuckyGiftGameRecord(LuckGiftGameQryCmd query) {
    return gameLuckyGiftConfigService.pageLuckyGiftGameRecord(query);
  }

  /**
   * 统计查询条件结果.
   */
  @GetMapping("/count")
  public GameLuckyGiftCountDTO countLuckyGiftGame(LuckGiftGameCountQryCmd query) {
    return gameLuckyGiftConfigService.countLuckyGiftGame(query);
  }

  /**
   * 获取幸运礼物规格配置Map.
   */
  @GetMapping("/map/probability")
  public List<LuckyGiftStandardMapDTO> mapLuckyGiftStandard(String sysOrigin) {
    return gameLuckyGiftConfigService.listProbability(sysOrigin);
  }

  /**
   * 获取幸运礼物规则配置
   */
  @GetMapping("/rule-config")
  public GameLuckyGiftRuleConfigDTO getLuckyGiftRuleConfig(
      GameLuckGiftRuleConfigQryCmd query) {
    return gameLuckyGiftConfigService.getLuckyGiftRuleConfig(query);
  }

  /**
   * 幸运礼物规则配置-存在即修改.
   */
  @PostMapping("/rule-config")
  public void addLuckyGiftRuleConfig(
      @RequestBody @Validated GameLuckyGiftRuleConfigDTO param) {
    param.setOperationUser(getReqUserId());
    gameLuckyGiftConfigService.addLuckyGiftRuleConfig(param);
  }

  /**
   * 获幸运礼物规格配置信息.
   */
  @GetMapping("/standard-config")
  public PageResult<GameLuckyGiftStandardConfigDTO> getStandardConfig(
      GameLuckGiftStandardConfigQryCmd query) {
    return gameLuckyGiftConfigService.getStandardConfig(query);
  }

  /**
   * 新增/修改礼物规格配置.
   */
  @PostMapping("/standard-config")
  public void addLuckyGiftStandardConfig(
      @RequestBody @Validated GameLuckyGiftStandardConfigDTO param) {
    param.setOperationUser(getReqUserId());
    gameLuckyGiftConfigService.addLuckyGiftStandardConfig(param);
  }

  /**
   * 删除礼物规格配置.
   */
  @DeleteMapping("/standard-config/{id}")
  public void deleteStandardConfig(@PathVariable("id") Long id) {
    gameLuckyGiftConfigService.deleteStandardConfig(id, getReqUserId());
  }

  /**
   * 获取幸运礼物规格概率基础配置
   */
  @GetMapping("/probability-info-config")
  public List<GameLuckyGiftProbabilityDTO> getLuckyGiftProbabilityInfoConfig(
      GameLuckGiftProbabilityConfigQryCmd query) {
    return gameLuckyGiftConfigService.getLuckyGiftProbabilityConfig(query);
  }

  /**
   * 新增/修改礼物规格概率基础配置和详情配置.
   */
  @PostMapping("/probability-info-config")
  public void addLuckyGiftProbabilityInfoConfig(
      @RequestBody @Validated GameLuckyGiftProbabilityInfoDTO param) {
    param.setOperationUser(getReqUserId());
    gameLuckyGiftConfigService.addLuckyGiftProbabilityInfoConfig(param);
  }


}
