package com.fdage.controller;

import com.fdage.aop.WebControllerLog;
import com.fdage.dto.SceneDto;
import com.fdage.dto.VideoDto;
import com.fdage.entity.SceneEntity;
import com.fdage.entity.VideoEntity;
import com.fdage.service.SceneService;
import com.fdage.service.VideoService;
import com.fdage.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * Created by owen on 2021/8/30 0023 15:35
 */
@ApiIgnore
@Api(tags = "视频管理")
@RestController
@RequestMapping("/zhoushan/video")
public class VideoController {
    @Autowired
    VideoService videoService;

    @ApiOperation("列表")
    @PostMapping("list")
    public Result list() {
        return videoService.findAll();
    }

    @WebControllerLog(description = "视频管理-新增/编辑")
    @ApiOperation("新增/编辑")
    @PostMapping("save")
    public Result<VideoEntity> save(@Valid @RequestBody VideoDto param) {
        return videoService.saveEntity(param);
    }


    @WebControllerLog(description = "视频管理-删除")
    @ApiOperation(value = "删除", notes = "db数据软删除， 物理数据真删除")
    @GetMapping("remove/{id}")
    public Result remove(@PathVariable Long id) {
        return videoService.remove(id);
    }

    @WebControllerLog(description = "视频管理-详情")
    @ApiOperation(value = "详情")
    @GetMapping("detail/{id}")
    public Result detail(@PathVariable Long id) {

        return videoService.detail(id);
    }


    @ApiOperation(value = "上传", notes = "重命名文件")
    @PostMapping("upload")
    public Result upload(MultipartFile file) {

        return videoService.upload(file, null, false);
    }
}
