package com.fs.delivery.controller;

import java.util.List;
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.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.delivery.domain.CtLongVideo;
import com.fs.delivery.service.ICtLongVideoService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 长视频Controller
 * 
 * @author fs
 * @date 2026-01-22
 */
@RestController
@RequestMapping("/delivery/video")
public class CtLongVideoController extends BaseController
{
    @Autowired
    private ICtLongVideoService ctLongVideoService;

    /**
     * 查询长视频列表
     */
    @PreAuthorize("@ss.hasPermi('delivery:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(CtLongVideo ctLongVideo)
    {
        startPage();
        List<CtLongVideo> list = ctLongVideoService.selectCtLongVideoList(ctLongVideo);
        return getDataTable(list);
    }

    /**
     * 导出长视频列表
     */
    @PreAuthorize("@ss.hasPermi('delivery:video:export')")
    @Log(title = "长视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CtLongVideo ctLongVideo)
    {
        List<CtLongVideo> list = ctLongVideoService.selectCtLongVideoList(ctLongVideo);
        ExcelUtil<CtLongVideo> util = new ExcelUtil<CtLongVideo>(CtLongVideo.class);
        return util.exportExcel(list, "长视频数据");
    }

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

    /**
     * 新增长视频
     */
    @PreAuthorize("@ss.hasPermi('delivery:video:add')")
    @Log(title = "长视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CtLongVideo ctLongVideo)
    {
        return toAjax(ctLongVideoService.insertCtLongVideo(ctLongVideo));
    }

    /**
     * 修改长视频
     */
    @PreAuthorize("@ss.hasPermi('delivery:video:edit')")
    @Log(title = "长视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CtLongVideo ctLongVideo)
    {
        return toAjax(ctLongVideoService.updateCtLongVideo(ctLongVideo));
    }

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