package com.zhongzheng.controller.polyv;

import com.zhongzheng.common.core.domain.model.LoginUser;
import com.zhongzheng.common.utils.ServletUtils;
import com.zhongzheng.framework.web.service.TokenService;
import com.zhongzheng.modules.polyv.vo.PolyvVideoQuerVo;
import com.zhongzheng.modules.polyv.vo.PolyvVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.modules.polyv.service.IPolyvVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 保利威视频信息Controller
 *
 * @author zhongzheng
 * @date 2021-06-11
 */
@Api(value = "保利威视频信息控制器", tags = {"保利威视频信息管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/polyv/video")
public class PolyvVideoController extends BaseController {

    private final IPolyvVideoService iPolyvVideoService;

    @Autowired
    private TokenService tokenService;
    /**
     * 获取保利威视频信息详细信息
     */
    @ApiOperation("获取保利威视频信息详细信息")
    @GetMapping("/{vid}")
    public AjaxResult<PolyvVideoQuerVo> getInfo(@PathVariable("vid") String vid) throws Exception {
        return AjaxResult.success(iPolyvVideoService.queryById(vid));
    }

    @ApiOperation("获取保利威视频播放凭证")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:query')")
    @GetMapping("/sign/{vid}")
    public AjaxResult<String> getPlayPcSign(@PathVariable("vid") String vid) throws Exception {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String viewerId = String.valueOf(loginUser.getUser().getUserId());
        String token = iPolyvVideoService.polyvbPcSignRequest(vid,viewerId);
        return AjaxResult.success("成功",token);
    }

    /**
     * 获取保利威视频信息详细信息
     */
    @ApiOperation("获取保利威视频上传签名")
    @GetMapping("/getPolyvUpload")
    public AjaxResult<PolyvVo> getPolyvUpload() throws Exception {
        return AjaxResult.success(iPolyvVideoService.getPolyvUpload());
    }


   /* *//**
     * 查询保利威视频信息列表
     *//*
    @ApiOperation("查询保利威视频信息列表")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:list')")
    @GetMapping("/list")
    public TableDataInfo<PolyvVideoVo> list(PolyvVideoQueryBo bo) {
        startPage();
        List<PolyvVideoVo> list = iPolyvVideoService.queryList(bo);
        return getDataTable(list);
    }

    *//**
     * 导出保利威视频信息列表
     *//*
    @ApiOperation("导出保利威视频信息列表")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:export')")
    @Log(title = "保利威视频信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<PolyvVideoVo> export(PolyvVideoQueryBo bo) {
        List<PolyvVideoVo> list = iPolyvVideoService.queryList(bo);
        ExcelUtil<PolyvVideoVo> util = new ExcelUtil<PolyvVideoVo>(PolyvVideoVo.class);
        return util.exportExcel(list, "保利威视频信息");
    }*/


/*
    *//**
     * 新增保利威视频信息
     *//*
    @ApiOperation("新增保利威视频信息")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:add')")
    @Log(title = "保利威视频信息", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody PolyvVideoAddBo bo) {
        return toAjax(iPolyvVideoService.insertByAddBo(bo) ? 1 : 0);
    }

    *//**
     * 修改保利威视频信息
     *//*
    @ApiOperation("修改保利威视频信息")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:edit')")
    @Log(title = "保利威视频信息", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody PolyvVideoEditBo bo) {
        return toAjax(iPolyvVideoService.updateByEditBo(bo) ? 1 : 0);
    }*/

 /*   *//**
     * 删除保利威视频信息
     *//*
    @ApiOperation("删除保利威视频信息")
    @PreAuthorize("@ss.hasPermi('modules.polyv:video:remove')")
    @Log(title = "保利威视频信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{polyvIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] polyvIds) {
        return toAjax(iPolyvVideoService.deleteWithValidByIds(Arrays.asList(polyvIds), true) ? 1 : 0);
    }*/
}
