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

import com.red.circle.common.business.dto.cmd.IdLongCmd;
import com.red.circle.console.app.service.app.game.GameKtvConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.game.GameKtvConfigQryCmd;
import com.red.circle.other.inner.model.dto.game.GameKtvConfigDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ktv歌曲配置信息 前端控制器.
 *
 * @author zongpubin on 2023-05-05 17:18
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/game-ktv/config")
public class GameKtvConfigRestController extends BaseController {

  private final GameKtvConfigService gameKtvConfigService;

  /**
   * 获取歌曲信息.
   */
  @GetMapping
  public PageResult<GameKtvConfigDTO> getSongInfo(@Validated GameKtvConfigQryCmd query) {
    return gameKtvConfigService.getSongInfo(query);
  }

  @OpsOperationReqLog(value = "新增歌曲信息")
  @PostMapping
  public void addSong(@RequestBody GameKtvConfigDTO param) {
    param.setCreateUser(param.getReqUserId());
    gameKtvConfigService.addSong(param);
  }

  @OpsOperationReqLog(value = "修改歌曲信息")
  @PutMapping
  public void updateGift(@RequestBody GameKtvConfigDTO param) {
    param.setUpdateUser(param.getReqUserId());
    gameKtvConfigService.updateSong(param);
  }

  /**
   * 上下架歌曲.
   */
  @PutMapping("/switch/{id}/{status}")
  public void switchShelfStatus(@PathVariable("id") Long id,
      @PathVariable("status") Boolean status) {
    gameKtvConfigService.switchShelfStatus(id, status);
  }

  /**
   * 删除歌曲.
   */
  @PutMapping("/delete")
  public void deleteSong(@RequestBody IdLongCmd cmd) {
    gameKtvConfigService.deleteSong(cmd.getId(), cmd.getReqUserId());
  }

}
