package com.ruoyi.web.controller.back;

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

import com.ruoyi.syzy.domain.BWwwNewsVideo;
import com.ruoyi.syzy.service.IBWwwNewsVideoService;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资讯视频Controller
 * 
 * @author voluntary
 * @date 2023-03-20
 */
@RestController
@RequestMapping("/back/bWwwNewsVideo")
public class BackWwwNewsVideoController extends BaseController
{
    @Autowired
    private IBWwwNewsVideoService bWwwNewsVideoService;

    /**
     * 查询资讯视频列表
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BWwwNewsVideo bWwwNewsVideo)
    {
        startPage();
        List<BWwwNewsVideo> list = bWwwNewsVideoService.selectBWwwNewsVideoList(bWwwNewsVideo);
        return getDataTable(list);
    }

    /**
     * 导出资讯视频列表
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:export')")
    @Log(title = "资讯视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BWwwNewsVideo bWwwNewsVideo)
    {
        List<BWwwNewsVideo> list = bWwwNewsVideoService.selectBWwwNewsVideoList(bWwwNewsVideo);
        ExcelUtil<BWwwNewsVideo> util = new ExcelUtil<BWwwNewsVideo>(BWwwNewsVideo.class);
        util.exportExcel(response, list, "资讯视频数据");
    }

    /**
     * 获取资讯视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bWwwNewsVideoService.selectBWwwNewsVideoById(id));
    }

    /**
     * 新增资讯视频
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:add')")
    @Log(title = "资讯视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BWwwNewsVideo bWwwNewsVideo)
    {
        return toAjax(bWwwNewsVideoService.insertBWwwNewsVideo(bWwwNewsVideo));
    }

    /**
     * 修改资讯视频
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:edit')")
    @Log(title = "资讯视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BWwwNewsVideo bWwwNewsVideo)
    {
        return toAjax(bWwwNewsVideoService.updateBWwwNewsVideo(bWwwNewsVideo));
    }

    /**
     * 删除资讯视频
     */
    @PreAuthorize("@ss.hasPermi('back:bWwwNewsVideo:remove')")
    @Log(title = "资讯视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bWwwNewsVideoService.deleteBWwwNewsVideoByIds(ids));
    }
}
