package com.ruoyi.system.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.system.domain.CpsGlbViewCfg;
import com.ruoyi.system.service.ICpsGlbViewCfgService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cps_glb_view_cfg 展示配置Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/cp/viewcfg")
public class CpsGlbViewCfgController extends BaseController
{
    @Autowired
    private ICpsGlbViewCfgService cpsGlbViewCfgService;

    /**
     * 查询cps_glb_view_cfg 展示配置列表
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:list')")
    @GetMapping("/list")
    public TableDataInfo list(CpsGlbViewCfg cpsGlbViewCfg)
    {
        startPage();
        List<CpsGlbViewCfg> list = cpsGlbViewCfgService.selectCpsGlbViewCfgList(cpsGlbViewCfg);
        return getDataTable(list);
    }

    /**
     * 导出cps_glb_view_cfg 展示配置列表
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:export')")
    @Log(title = "cps_glb_view_cfg 展示配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CpsGlbViewCfg cpsGlbViewCfg)
    {
        List<CpsGlbViewCfg> list = cpsGlbViewCfgService.selectCpsGlbViewCfgList(cpsGlbViewCfg);
        ExcelUtil<CpsGlbViewCfg> util = new ExcelUtil<CpsGlbViewCfg>(CpsGlbViewCfg.class);
        util.exportExcel(response, list, "cps_glb_view_cfg 展示配置数据");
    }

    /**
     * 获取cps_glb_view_cfg 展示配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cpsGlbViewCfgService.selectCpsGlbViewCfgById(id));
    }

    /**
     * 新增cps_glb_view_cfg 展示配置
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:add')")
    @Log(title = "cps_glb_view_cfg 展示配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CpsGlbViewCfg cpsGlbViewCfg)
    {
        return toAjax(cpsGlbViewCfgService.insertCpsGlbViewCfg(cpsGlbViewCfg));
    }

    /**
     * 修改cps_glb_view_cfg 展示配置
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:edit')")
    @Log(title = "cps_glb_view_cfg 展示配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CpsGlbViewCfg cpsGlbViewCfg)
    {
        return toAjax(cpsGlbViewCfgService.updateCpsGlbViewCfg(cpsGlbViewCfg));
    }

    /**
     * 删除cps_glb_view_cfg 展示配置
     */
    @PreAuthorize("@ss.hasPermi('cp:viewcfg:remove')")
    @Log(title = "cps_glb_view_cfg 展示配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cpsGlbViewCfgService.deleteCpsGlbViewCfgByIds(ids));
    }
}
