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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.game.GameLuckyBoxCO;
import com.red.circle.other.app.dto.clientobject.game.GameLuckyBoxRewardCO;
import com.red.circle.other.app.dto.clientobject.game.GameLuckyUserListCO;
import com.red.circle.other.app.dto.cmd.game.GameLuckyBoxDrawCmd;
import com.red.circle.other.app.service.game.GameLuckyBoxService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * <p>
 * lucky box 前端控制器.
 * </p>
 *
 * @author pengshigang
 * @eo.api-type http
 * @eo.groupName 游戏服务.LuckyBox
 * @eo.path /game/lucky-box
 * @since 2021-07-13
 */
@Slf4j
@RestController
@RequestMapping(value = "/game/lucky-box", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GameLuckyBoxRestController extends BaseController {

  private final GameLuckyBoxService gameLuckyBoxService;

  /**
   * 获取游戏规则与游戏奖品.
   *
   * @eo.name 获取游戏规则与游戏奖品.
   * @eo.url /gift
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/gift")
  public GameLuckyBoxCO gift(AppExtCommand cmd) {
    return gameLuckyBoxService.gift(cmd);
  }


  /**
   * 抽奖.
   *
   * @eo.name 抽奖.
   * @eo.url /luck-draw
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/luck-draw")
  public List<GameLuckyBoxRewardCO> luckDraw(@RequestBody @Validated GameLuckyBoxDrawCmd cmd) {
    return gameLuckyBoxService.luckDraw(cmd);
  }

  /**
   * 幸运用户列表.
   *
   * @eo.name 幸运用户列表.
   * @eo.url /lucky/user/list
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/lucky/user/list")
  public List<GameLuckyUserListCO> luckyUserList(AppExtCommand cmd) {
    return gameLuckyBoxService.luckyUserList(cmd);
  }

}
