package cn.api.atv;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.websocket.Session;

import cn.pojo.atv.AtvBroadcast;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.common.annotation.Log;
import cn.common.enums.BizOpType;
import cn.common.page.response.Result;
import cn.pojo.atv.AtvTts;
import cn.service.atv.IAtvService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.web.multipart.MultipartFile;

/**
 * TTS语音表
 */
@RestController
@RequestMapping("/api/broadcast")
public class AtvTtsCtrl {
    @Resource
    private IAtvService atvService;

    public static Map<String, List<Session>> turnTts = new HashMap<>();
    public static Map<String, List<Session>> playTts = new HashMap<>();

    @GetMapping("/uploadTts")
    @Log(title = "远程广播-上传音频信息-uploadTts", businessType = BizOpType.OTHER)
    public Result<?> uploadTts(@RequestBody AtvTts entity) {
        return Result.ok(atvService.uploadTts(entity));
    }

    @GetMapping(value = "/playTts")
    @Log(title = "TTS语音表-播放-playTts", businessType = BizOpType.OTHER)
    public Result<?> playTts(@RequestParam(name = "id") String id) {
        return Result.ok(atvService.playTts(id));
    }

    @PostMapping(value = "/playVoice")
    @Log(title = "远程喊话-playVoice", businessType = BizOpType.OTHER)
    public Result<?> playVoice(MultipartFile files, @RequestParam("id") String id) throws Exception {
        return Result.ok(atvService.playVoice(id, files));
    }

    /**
     * 目前没有用几号命令
     */
    @PostMapping("/uploadText")
    @Log(title = "远程广播-上传文本信息-uploadText", businessType = BizOpType.OTHER)
    public Result<?> uploadText(@RequestBody AtvBroadcast entity) {
        return Result.ok(atvService.uploadText(entity));
    }
}
