package com.tuoheng.admin.controller;

import com.tuoheng.admin.service.aliyun.IAliyuncsVodService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 阿里云点播服务 前端控制器
 *
 * @author WangHaoran
 * @since 2022-03-10
 */
@RestController
@RequestMapping("/aliyuncsVod")
public class AliyuncsVodController {

    @Autowired
    IAliyuncsVodService aliyuncsVodService;


    /**
     * 获取音视频上传地址和凭证
     *
     * @param title
     * @param fileName
     * @return
     */
    @GetMapping("/createUploadVideo")
    public JsonResult createUploadVideo(String title, String fileName) {
        return JsonResult.success(aliyuncsVodService.createUploadVideo(title, fileName));
    }


    /**
     * 刷新音/视频上传凭证
     *
     * @param videoId 音频或视频ID
     * @return
     */
    @GetMapping("/refreshUploadVideo")
    public JsonResult refreshUploadVideo(String videoId) {
        return JsonResult.success(aliyuncsVodService.refreshUploadVideo(videoId));
    }
}
