package com.ruoyi.web.controller.test.gl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.test.domain.Video;
import com.ruoyi.test.domain.Vo.VideoVo;
import com.ruoyi.test.seriver.IVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "管理端视频管理")
@RestController
@RequestMapping("/gl/video")
public class VideoController {
    @Autowired
    private IVideoService iVideoService;

    @ApiOperation("视频列表")
    @GetMapping("selectList")
    public R<IPage<Video>> selectList(int pagenum){
        return R.ok(iVideoService.selectList(pagenum));
    }

    @ApiOperation("根据年级获取视频列表")
    @GetMapping("selectListByGrate")
    public R<IPage<Video>> selectListByGrate(String grade,int pagenum){
        return R.ok(iVideoService.selectListByGrate(grade,pagenum));
    }

    @ApiOperation("删除视频")
    @DeleteMapping("deleteVideo")
    public R<String> deleteVideo(Long id){
        if(iVideoService.deleteVideo(id)!=0){
            return R.ok("删除成功！");
        }
        return R.fail("删除失败！");
    }

    @ApiOperation("视频创编")
    @PostMapping("addVideo")
    public R<String> addVideo(@RequestBody VideoVo videoVo){
        if(iVideoService.addVideo(videoVo)!=0){
            return R.ok("创建成功！");
        }
        return R.fail("创建失败");
    }


    }
