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

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.clientobject.game.GameKtvCO;
import com.red.circle.other.app.dto.clientobject.game.GameKtvClickedSongCO;
import com.red.circle.other.app.dto.clientobject.game.GameKtvUserProfileCO;
import com.red.circle.other.app.dto.cmd.game.GameKtvClickSongCmd;
import com.red.circle.other.app.dto.cmd.game.GameKtvRemoveSongCmd;
import com.red.circle.other.app.service.game.GameKtvService;
import java.util.List;
import java.util.Map;
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;

/**
 * ktv游戏.
 *
 * @author lisizhe on 2023/9/25
 * @eo.api-type http
 * @eo.groupName 游戏服务.ktv游戏
 * @eo.path /game/ktv
 */
@Slf4j
@RestController
@RequestMapping(value = "/game/ktv", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class GameKtvRestController extends BaseController {

  private final GameKtvService gameKtvService;

  /**
   * 获得秒倒计时.
   *
   * @eo.name 获得秒倒计时
   * @eo.url /count-down
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/count-down")
  public Map<String, Long> getCountDown(@Validated AppRoomIdCmd cmd) {
    return gameKtvService.getCountDown(cmd);
  }

  /**
   * 获得ktv基础数据.
   *
   * @eo.name 获得ktv基础数据
   * @eo.url /base
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/base")
  public GameKtvCO getKtvData(@Validated AppRoomIdCmd cmd) {
    return gameKtvService.getKtvData(cmd);
  }

  /**
   * 获得ktv已点歌曲.
   *
   * @eo.name 获得ktv已点歌曲
   * @eo.url /clicked-songs
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/clicked-songs")
  public List<GameKtvClickedSongCO> listKtvClickedSongs(@Validated AppRoomIdCmd cmd) {
    return gameKtvService.listKtvClickedSongs(cmd);
  }

  /**
   * 周榜单.
   *
   * @eo.name 周榜单
   * @eo.url /week-rank
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/week-rank")
  public List<GameKtvUserProfileCO> listWeekRank(AppExtCommand cmd) {
    return gameKtvService.listWeekRank(cmd);
  }

  /**
   * 点歌.
   *
   * @eo.name 点歌
   * @eo.url /click-song
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/click-song")
  public void clickSong(@RequestBody @Validated GameKtvClickSongCmd cmd) {
    gameKtvService.clickSong(cmd);
  }

  /**
   * 歌曲置顶.
   *
   * @eo.name 歌曲置顶
   * @eo.url /top
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/top")
  public void songTop(@RequestBody @Validated AppIdLongCmd cmd) {
    gameKtvService.songTop(cmd);
  }

  /**
   * 结束歌曲.
   *
   * @eo.name 结束歌曲
   * @eo.url /end
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/end")
  public void songEnd(@RequestBody @Validated AppIdLongCmd cmd) {
    gameKtvService.songEnd(cmd);
  }

  /**
   * 歌曲播放.
   *
   * @eo.name 歌曲播放
   * @eo.url /play
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/play")
  public void songPlay(@RequestBody @Validated AppIdLongCmd cmd) {
    gameKtvService.songPlay(cmd);
  }

  /**
   * 删除部分歌曲.
   *
   * @eo.name 删除部分歌曲
   * @eo.url /removes
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/removes")
  public void removeSongs(@RequestBody @Validated GameKtvRemoveSongCmd cmd) {
    gameKtvService.removeSongs(cmd);
  }

  /**
   * 删除准备中的歌曲.
   *
   * @eo.name 删除准备中的歌曲
   * @eo.url /del-wait
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/del-wait")
  public void delWaitSong(@RequestBody @Validated AppIdLongCmd cmd) {
    gameKtvService.delWaitSong(cmd);
  }


}
