package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.VideoContent;
import com.ruoyi.abuwx.service.IVideoContentService;
import com.ruoyi.abuwx.vo.VideoContentVo;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 视频信息Controller
 *
 * @author lujie
 * @date 2025-01-13
 */
@RestController
@RequestMapping("/video/content")
public class VideoContentController extends BaseController
{
    @Autowired
    private IVideoContentService videoContentService;

    /**
     * 查询视频信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(VideoContent videoContent)
    {
        startPage();
        List<VideoContentVo> list = videoContentService.selectVideoContentVoList(videoContent);
        return getDataTable(list);
    }

    /**
     * 导出视频信息列表
     */
    @PreAuthorize("@ss.hasPermi('video:content:export')")
    @Log(title = "视频信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoContent videoContent)
    {
        List<VideoContent> list = videoContentService.selectVideoContentList(videoContent);
        ExcelUtil<VideoContent> util = new ExcelUtil<VideoContent>(VideoContent.class);
        util.exportExcel(response, list, "视频信息数据");
    }

    /**
     * 获取视频信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:content:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(videoContentService.selectVideoContentById(id));
    }

    /**
     * 新增视频信息
     */
    @PreAuthorize("@ss.hasPermi('video:content:add')")
    @Log(title = "视频信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoContent videoContent)
    {
        return toAjax(videoContentService.insertVideoContent(videoContent));
    }

    /**
     * 修改视频信息
     */
    @PreAuthorize("@ss.hasPermi('video:content:edit')")
    @Log(title = "视频信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoContent videoContent)
    {
        return toAjax(videoContentService.updateVideoContent(videoContent));
    }

    /**
     * 删除视频信息
     */
    @PreAuthorize("@ss.hasPermi('video:content:remove')")
    @Log(title = "视频信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoContentService.deleteVideoContentByIds(ids));
    }
}
