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.CtShortVideo;
import com.fs.delivery.service.ICtShortVideoService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 长视频Controller
 * 
 * @author fs
 * @date 2026-01-22
 */
@RestController
@RequestMapping("/delivery/shortVideo")
public class CtShortVideoController extends BaseController
{
    @Autowired
    private ICtShortVideoService ctShortVideoService;

    /**
     * 查询长视频列表
     */
    @PreAuthorize("@ss.hasPermi('delivery:shortVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CtShortVideo ctShortVideo)
    {
        startPage();
        List<CtShortVideo> list = ctShortVideoService.selectCtShortVideoList(ctShortVideo);
        return getDataTable(list);
    }

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

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

    /**
     * 新增长视频
     */
    @PreAuthorize("@ss.hasPermi('delivery:shortVideo:add')")
    @Log(title = "长视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CtShortVideo ctShortVideo)
    {
        return toAjax(ctShortVideoService.insertCtShortVideo(ctShortVideo));
    }

    /**
     * 修改长视频
     */
    @PreAuthorize("@ss.hasPermi('delivery:shortVideo:edit')")
    @Log(title = "长视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CtShortVideo ctShortVideo)
    {
        return toAjax(ctShortVideoService.updateCtShortVideo(ctShortVideo));
    }

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