package com.dkl.large.controller;

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

import com.dkl.large.domain.DklClip;
import com.dkl.large.service.IDklClipService;
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.dkl.common.annotation.Log;
import com.dkl.common.core.controller.BaseController;
import com.dkl.common.core.domain.AjaxResult;
import com.dkl.common.enums.BusinessType;
import com.dkl.common.utils.poi.ExcelUtil;
import com.dkl.common.core.page.TableDataInfo;

/**
 * 视频Controller
 *
 * @author Dkl
 * @date 2025-11-03
 */
@RestController
@RequestMapping("/large/clip")
public class DklClipController extends BaseController
{
    @Autowired
    private IDklClipService dklClipService;

    /**
     * 查询视频列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DklClip dklClip)
    {
        startPage();
        List<DklClip> list = dklClipService.selectDklClipList(dklClip);
        return getDataTable(list);
    }

    /**
     * 导出视频列表
     */
    @Log(title = "视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DklClip dklClip)
    {
        List<DklClip> list = dklClipService.selectDklClipList(dklClip);
        ExcelUtil<DklClip> util = new ExcelUtil<DklClip>(DklClip.class);
        util.exportExcel(response, list, "视频数据");
    }

    /**
     * 获取视频详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dklClipService.selectDklClipById(id));
    }

    /**
     * 新增视频
     */
    @Log(title = "视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DklClip dklClip)
    {
        return toAjax(dklClipService.insertDklClip(dklClip));
    }

    /**
     * 修改视频
     */
    @Log(title = "视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DklClip dklClip)
    {
        return toAjax(dklClipService.updateDklClip(dklClip));
    }

    /**
     * 删除视频
     */
    @Log(title = "视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dklClipService.deleteDklClipByIds(ids));
    }
}
