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.SiteConfig;
import com.ruoyi.system.service.ISiteConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 系统配置Controller
 * 
 * @author ruoyi
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/system/SiteConfig")
public class SiteConfigController extends BaseController
{
    @Autowired
    private ISiteConfigService siteConfigService;

    /**
     * 查询系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteConfig siteConfig)
    {
        startPage();
        List<SiteConfig> list = siteConfigService.selectSiteConfigList(siteConfig);
        return getDataTable(list);
    }

    /**
     * 导出系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:export')")
    @Log(title = "系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SiteConfig siteConfig)
    {
        List<SiteConfig> list = siteConfigService.selectSiteConfigList(siteConfig);
        ExcelUtil<SiteConfig> util = new ExcelUtil<SiteConfig>(SiteConfig.class);
        util.exportExcel(response, list, "系统配置数据");
    }

    /**
     * 获取系统配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(siteConfigService.selectSiteConfigById(id));
    }

    /**
     * 新增系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:add')")
    @Log(title = "系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteConfig siteConfig)
    {
        return toAjax(siteConfigService.insertSiteConfig(siteConfig));
    }

    /**
     * 修改系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:edit')")
    @Log(title = "系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteConfig siteConfig)
    {
        return toAjax(siteConfigService.updateSiteConfig(siteConfig));
    }

    /**
     * 删除系统配置
     */
    @PreAuthorize("@ss.hasPermi('system:SiteConfig:remove')")
    @Log(title = "系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(siteConfigService.deleteSiteConfigByIds(ids));
    }
}
