package com.ruoyi.web.controller.system;

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

import com.ruoyi.system.domain.vo.FilleVo;
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.system.domain.SysRotograph;
import com.ruoyi.system.service.ISysRotographService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮播图附件Controller
 * 
 * @author ruoyi
 * @date 2023-02-24
 */
@RestController
@RequestMapping("/system/rotograph")
public class SysRotographController extends BaseController
{
    @Autowired
    private ISysRotographService sysRotographService;

    /**
     * 查询轮播图附件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysRotograph sysRotograph)
    {
        startPage();
        List<SysRotograph> list = sysRotographService.selectSysRotographList(sysRotograph);
        return getDataTable(list);
    }

    /**
     * 导出轮播图附件列表
     */
    @Log(title = "轮播图附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysRotograph sysRotograph)
    {
        List<SysRotograph> list = sysRotographService.selectSysRotographList(sysRotograph);
        ExcelUtil<SysRotograph> util = new ExcelUtil<SysRotograph>(SysRotograph.class);
        util.exportExcel(response, list, "轮播图附件数据");
    }

    /**
     * 获取轮播图附件详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rotograph:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysRotographService.selectSysRotographById(id));
    }

    /**
     * 新增轮播图附件
     */
    @Log(title = "轮播图附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRotograph sysRotograph)
    {
        return toAjax(sysRotographService.insertSysRotograph(sysRotograph));
    }

    /**
     * 修改轮播图附件
     */
    @PreAuthorize("@ss.hasPermi('system:rotograph:edit')")
    @Log(title = "轮播图附件", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody SysRotograph sysRotograph)
    {
        return toAjax(sysRotographService.updateSysRotograph(sysRotograph));
    }

    /**
     * 删除轮播图附件
     */
    @PreAuthorize("@ss.hasPermi('system:rotograph:remove')")
    @Log(title = "轮播图附件", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysRotographService.deleteSysRotographByIds(ids));
    }
}
