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

import com.red.circle.common.business.dto.cmd.RoomIdCmd;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.other.app.dto.clientobject.game.GameIndoorTeamPkCO;
import com.red.circle.other.app.dto.clientobject.game.GameIndoorTeamPkTopThreeFansCO;
import com.red.circle.other.app.dto.cmd.game.GameCreteIndoorPkCmd;
import com.red.circle.other.app.service.game.GameIndoorTeamPkService;
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>
 * 房间里面团队PK 前端控制器.
 * </p>
 *
 * @author lisizhe on 2023/9/19
 * @eo.api-type http
 * @eo.groupName 游戏服务.房间内团队PK服务
 * @eo.path /game/indoor/team/pk
 */
@Slf4j
@RestController
@RequestMapping(value = "/game/indoor/team/pk", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GameIndoorTeamPkRestController {

  private final GameIndoorTeamPkService gameIndoorTeamPkService;

  /**
   * 发起PK.
   *
   * @eo.name 发起PK
   * @eo.url /create
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/create")
  public void create(@RequestBody @Validated GameCreteIndoorPkCmd cmd) {
    gameIndoorTeamPkService.create(cmd);
  }

  /**
   * 开始PK.
   *
   * @eo.name 开始PK
   * @eo.url /start
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/start")
  public void start(@RequestBody @Validated AppIdLongCmd cmd) {
    gameIndoorTeamPkService.start(cmd);
  }

  /**
   * 取消PK.
   *
   * @eo.name 取消PK
   * @eo.url /cancel
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/cancel")
  public void cancel(@RequestBody @Validated AppIdLongCmd cmd) {
    gameIndoorTeamPkService.cancel(cmd);
  }

  /**
   * PK详细信息.(旧：base_info)
   *
   * @eo.name PK详细信息
   * @eo.url /base-info
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/base-info")
  public GameIndoorTeamPkCO baseInfo(@Validated RoomIdCmd cmd) {
    return gameIndoorTeamPkService.baseInfo(cmd);
  }

  /**
   * 双方前三名粉丝.（旧：team_top_three_fans）
   *
   * @eo.name 双方前三名粉丝
   * @eo.url /team-top-three-fans
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/team-top-three-fans")
  public GameIndoorTeamPkTopThreeFansCO teamTopThreeFans(@Validated AppIdLongCmd cmd) {
    return gameIndoorTeamPkService.teamTopThreeFans(cmd);
  }


}
