package com.ruoyi.model.controller;

import java.io.IOException;
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.model.domain.FinalConfig;
import com.ruoyi.model.service.IFinalConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 最终准备页面配置Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/model/FinalConfig")
public class FinalConfigController extends BaseController
{
    @Autowired
    private IFinalConfigService finalConfigService;

    /**
     * 查询最终准备页面配置列表
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(FinalConfig finalConfig)
    {
        startPage();
        List<FinalConfig> list = finalConfigService.selectFinalConfigList(finalConfig);
        return getDataTable(list);
    }

    /**
     * 导出最终准备页面配置列表
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:export')")
    @Log(title = "最终准备页面配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinalConfig finalConfig) throws IOException {
        List<FinalConfig> list = finalConfigService.selectFinalConfigList(finalConfig);
        ExcelUtil<FinalConfig> util = new ExcelUtil<FinalConfig>(FinalConfig.class);
        util.exportExcel(response, list, "最终准备页面配置数据");
    }

    /**
     * 获取最终准备页面配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(finalConfigService.selectFinalConfigById(id));
    }

    /**
     * 新增最终准备页面配置
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:add')")
    @Log(title = "最终准备页面配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinalConfig finalConfig)
    {
        return toAjax(finalConfigService.insertFinalConfig(finalConfig));
    }

    /**
     * 修改最终准备页面配置
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:edit')")
    @Log(title = "最终准备页面配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinalConfig finalConfig)
    {
        return toAjax(finalConfigService.updateFinalConfig(finalConfig));
    }

    /**
     * 删除最终准备页面配置
     */
    @PreAuthorize("@ss.hasPermi('model:FinalConfig:remove')")
    @Log(title = "最终准备页面配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(finalConfigService.deleteFinalConfigByIds(ids));
    }
}
