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.CurrentConfig;
import com.ruoyi.model.service.ICurrentConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 等级配置Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@RestController
@RequestMapping("/model/CurrentConfig")
public class CurrentConfigController extends BaseController
{
    @Autowired
    private ICurrentConfigService currentConfigService;

    /**
     * 查询等级配置列表
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(CurrentConfig currentConfig)
    {
        startPage();
        List<CurrentConfig> list = currentConfigService.selectCurrentConfigList(currentConfig);
        return getDataTable(list);
    }

    /**
     * 导出等级配置列表
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:export')")
    @Log(title = "等级配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CurrentConfig currentConfig) throws IOException {
        List<CurrentConfig> list = currentConfigService.selectCurrentConfigList(currentConfig);
        ExcelUtil<CurrentConfig> util = new ExcelUtil<CurrentConfig>(CurrentConfig.class);
        util.exportExcel(response, list, "等级配置数据");
    }

    /**
     * 获取等级配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:query')")
    @GetMapping(value = "/{currentId}")
    public AjaxResult getInfo(@PathVariable("currentId") Long currentId)
    {
        return success(currentConfigService.selectCurrentConfigByCurrentId(currentId));
    }

    /**
     * 新增等级配置
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:add')")
    @Log(title = "等级配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CurrentConfig currentConfig)
    {
        return toAjax(currentConfigService.insertCurrentConfig(currentConfig));
    }

    /**
     * 修改等级配置
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:edit')")
    @Log(title = "等级配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CurrentConfig currentConfig)
    {
        return toAjax(currentConfigService.updateCurrentConfig(currentConfig));
    }

    /**
     * 删除等级配置
     */
    @PreAuthorize("@ss.hasPermi('model:CurrentConfig:remove')")
    @Log(title = "等级配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{currentIds}")
    public AjaxResult remove(@PathVariable Long[] currentIds)
    {
        return toAjax(currentConfigService.deleteCurrentConfigByCurrentIds(currentIds));
    }
}
