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

import com.red.circle.console.app.dto.clienobject.game.GameLuckyBoxCountCO;
import com.red.circle.console.app.service.app.game.GameLuckyBoxConfigService;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.game.GameLuckBoxAwardConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckBoxBountyConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckBoxFortuneValueConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckBoxStandardConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckyBoxAwardDetailsConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckyBoxBountyDetailsConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.GameLuckyBoxStandardDetailsConfigQryCmd;
import com.red.circle.other.inner.model.cmd.game.LuckBoxGameQryCmd;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxAwardConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxAwardDetailsConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxBountyConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxBountyDetailsConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxCountInfoDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxFortuneValueConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxGiftConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxStandardConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxStandardDetailsConfigDTO;
import com.red.circle.other.inner.model.dto.game.GameLuckyBoxTimeConfigDTO;
import com.red.circle.other.inner.model.dto.game.LuckyBoxGiftMapDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
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;

/**
 * 新版 Game Lucky Box 前端控制器.
 *
 * @author zongpubin
 * @since 2023-08-18
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/game/lucky-box")
public class GameLuckyBoxConfigRestController extends BaseController {

  private final GameLuckyBoxConfigService gameLuckyBoxConfigService;


  /**
   * 查询抽奖记录.
   */
  @GetMapping("/page/record")
  public PageResult<GameLuckyBoxCountCO> pageLuckyBoxGameRecord(LuckBoxGameQryCmd query) {
    return gameLuckyBoxConfigService.pageLuckyBoxGameRecord(query);
  }

  /**
   * 统计查询条件结果.
   */
  @GetMapping("/count")
  public GameLuckyBoxCountInfoDTO countLuckyBoxGame(LuckBoxGameQryCmd query) {
    return gameLuckyBoxConfigService.countLuckyBoxGame(query);
  }


  /**
   * 获取幸运值配置
   */
  @GetMapping("/fortune-config")
  public GameLuckyBoxFortuneValueConfigDTO getLuckyBoxFortuneValueConfig(
      GameLuckBoxFortuneValueConfigQryCmd query) {
    return gameLuckyBoxConfigService.getLuckyBoxFortuneValueConfig(query);
  }


  /**
   * 幸运值配置，存在即修改.
   */
  @PostMapping("/fortune-config")
  public void addLuckyBoxFortuneValueConfig(
      @RequestBody @Validated GameLuckyBoxFortuneValueConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addLuckyBoxFortuneValueConfig(param);
  }


  /**
   * 获赏金任务规格配置信息.
   */
  @GetMapping("/bounty-config")
  public PageResult<GameLuckyBoxBountyConfigDTO> getBountyConfig(
      GameLuckBoxBountyConfigQryCmd query) {
    return gameLuckyBoxConfigService.getBountyConfig(query);
  }

  /**
   * 新增/修改赏金任务规格配置.
   */
  @PostMapping("/bounty-config")
  public void addGameLuckyBoxBountyConfig(
      @RequestBody @Validated GameLuckyBoxBountyConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxBountyConfig(param);
  }

  /**
   * 删除赏金任务规格配置.
   */
  @DeleteMapping("/bounty-config/{id}")
  public void deleteBountyConfig(@PathVariable("id") Long id) {
    gameLuckyBoxConfigService.deleteBountyConfig(id);
  }

  /**
   * 获取赏金任务配置详情
   */
  @GetMapping("/bounty-details-config")
  public List<GameLuckyBoxBountyDetailsConfigDTO> getGameLuckyBoxBountyDetailsConfig(
      GameLuckyBoxBountyDetailsConfigQryCmd query) {
    return gameLuckyBoxConfigService.getGameLuckyBoxBountyDetailsConfig(query);
  }

  /**
   * 新增赏金任务配置详情.
   */
  @PostMapping("/bounty-details-config")
  public void addGameLuckyBoxBountyDetailsConfig(
      @RequestBody @Validated GameLuckyBoxBountyDetailsConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxBountyDetailsConfig(param);
  }

  /**
   * 删除赏金任务规格详情配置.
   */
  @DeleteMapping("/bounty-details-config/{id}")
  public void deleteBountyDetailsConfig(@PathVariable("id") Long id) {
    gameLuckyBoxConfigService.deleteBountyDetailsConfig(id);
  }

  /**
   * 累计抽奖奖励配置列表.
   */
  @GetMapping("/award-config")
  public PageResult<GameLuckyBoxAwardConfigDTO> getAwardConfig(
      GameLuckBoxAwardConfigQryCmd query) {
    return gameLuckyBoxConfigService.getAwardConfig(query);
  }

  /**
   * 新增/修改累计抽奖奖励配置.
   */
  @PostMapping("/award-config")
  public void addGameLuckyBoxAwardConfig(
      @RequestBody @Validated GameLuckyBoxAwardConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxAwardConfig(param);
  }

  /**
   * 删除累计抽奖奖励配置.
   */
  @DeleteMapping("/award-config/{id}")
  public void deleteAwardConfig(@PathVariable("id") Long id) {
    gameLuckyBoxConfigService.deleteAwardConfig(id);
  }

  /**
   * 获取累计抽奖奖励配置详情
   */
  @GetMapping("/award-details-config")
  public List<GameLuckyBoxAwardDetailsConfigDTO> getGameLuckyBoxAwardDetailsConfig(
      GameLuckyBoxAwardDetailsConfigQryCmd query) {
    return gameLuckyBoxConfigService.getGameLuckyBoxAwardDetailsConfig(query);
  }

  /**
   * 新增累计抽奖奖励配置详情.
   */
  @PostMapping("/award-details-config")
  public void addGameLuckyBoxAwardDetailsConfig(
      @RequestBody @Validated GameLuckyBoxAwardDetailsConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxAwardDetailsConfig(param);
  }

  /**
   * 删除累计抽奖奖励配置详情.
   */
  @Deprecated
  @DeleteMapping("/award-details-config/{id}")
  public void deleteAwardDetailsConfig(@PathVariable("id") Long id) {
    gameLuckyBoxConfigService.deleteAwardDetailsConfig(id);
  }

  /**
   * 获取抽奖规格配置信息.
   */
  @GetMapping("/standard-config")
  public PageResult<GameLuckyBoxStandardConfigDTO> getStandardConfig(
      GameLuckBoxStandardConfigQryCmd query) {
    return gameLuckyBoxConfigService.getStandardConfig(query);
  }

  /**
   * 新增/修改抽奖规格配置信息.
   */
  @PostMapping("/standard-config")
  public void addStandardConfig(
      @RequestBody @Validated GameLuckyBoxStandardConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addStandardConfig(param);
  }

  /**
   * 切换抽奖规格状态.
   */
  @PostMapping("/switch_status/{id}/{status}")
  public void switchStatus(@PathVariable("id") Long id,
      @PathVariable("status") Boolean status) {
    gameLuckyBoxConfigService.switchStatus(id, status);
  }

  /**
   * 删除抽奖规格配置.
   */
  @DeleteMapping("/standard-config/{id}")
  public void deleteStandardConfig(@PathVariable("id") Long id) {
    gameLuckyBoxConfigService.deleteStandardConfig(id);
  }

  /**
   * 获取抽奖礼物配置详情
   */
  @GetMapping("/gift-config")
  public List<GameLuckyBoxGiftConfigDTO> getGameLuckyBoxGiftConfig(
      GameLuckyBoxStandardDetailsConfigQryCmd query) {
    return gameLuckyBoxConfigService.getGameLuckyBoxGiftConfig(query);
  }

  /**
   * 新增/修改抽奖规格礼物配置.
   */
  @PostMapping("/gift-config")
  public void addGameLuckyBoxGiftConfig(
      @RequestBody @Validated GameLuckyBoxGiftConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxGiftConfig(param);
  }

  /**
   * 获取luckyBox礼物规格配置Map.
   */
  @GetMapping("/map/gift")
  public List<LuckyBoxGiftMapDTO> mapLuckyBoxGiftMap(
      GameLuckyBoxStandardDetailsConfigQryCmd query) {
    return gameLuckyBoxConfigService.mapLuckyBoxGiftMap(query);
  }


  /**
   * 获取抽奖规格配置详情
   */
  @GetMapping("/standard-details-config")
  public List<GameLuckyBoxTimeConfigDTO> getGameLuckyBoxStandardDetailsConfig(
      GameLuckyBoxStandardDetailsConfigQryCmd query) {
    return gameLuckyBoxConfigService.getGameLuckyBoxStandardDetailsConfig(query);
  }


  /**
   * 新增/修改抽奖规格配置详情.
   */
  @PostMapping("/standard-details-config")
  public void addGameLuckyBoxStandardDetailsConfig(
      @RequestBody @Validated GameLuckyBoxStandardDetailsConfigDTO param) {
    param.setOperationUser(param.getReqUserId());
    gameLuckyBoxConfigService.addGameLuckyBoxStandardDetailsConfig(param);
  }


}
