package com.ruoyi.szxc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.szxc.domain.SzxcLunbo;
import com.ruoyi.szxc.service.ISzxcLunboService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮播设置Controller
 * 
 * @author hs
 * @date 2024-03-16
 */
@RestController
@RequestMapping("/szxc/lunbo")
public class SzxcLunboController extends BaseController
{
    @Autowired
    private ISzxcLunboService szxcLunboService;

    /**
     * 查询轮播设置列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SzxcLunbo szxcLunbo)
    {
        startPage();
        List<SzxcLunbo> list = szxcLunboService.selectSzxcLunboList(szxcLunbo);
        return getDataTable(list);
    }

    /**
     * 导出轮播设置列表
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:export')")
    @Log(title = "轮播设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SzxcLunbo szxcLunbo)
    {
        List<SzxcLunbo> list = szxcLunboService.selectSzxcLunboList(szxcLunbo);
        ExcelUtil<SzxcLunbo> util = new ExcelUtil<SzxcLunbo>(SzxcLunbo.class);
        util.exportExcel(response, list, "轮播设置数据");
    }

    /**
     * 获取轮播设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(szxcLunboService.selectSzxcLunboById(id));
    }

    /**
     * 新增轮播设置
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:add')")
    @Log(title = "轮播设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SzxcLunbo szxcLunbo)
    {
        return toAjax(szxcLunboService.insertSzxcLunbo(szxcLunbo));
    }

    /**
     * 修改轮播设置
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:edit')")
    @Log(title = "轮播设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SzxcLunbo szxcLunbo)
    {
        return toAjax(szxcLunboService.updateSzxcLunbo(szxcLunbo));
    }

    /**
     * 删除轮播设置
     */
    @PreAuthorize("@ss.hasPermi('szxc:lunbo:remove')")
    @Log(title = "轮播设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(szxcLunboService.deleteSzxcLunboByIds(ids));
    }
}
