package com.cn.fdapfe.biz.controller;

import java.util.List;
import javax.annotation.Resource;
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.cn.fdapfe.common.annotation.Log;
import com.cn.fdapfe.common.core.controller.BaseController;
import com.cn.fdapfe.common.core.domain.AjaxResult;
import com.cn.fdapfe.common.enums.BusinessType;
import com.cn.fdapfe.biz.domain.Formulas;
import com.cn.fdapfe.biz.service.IFormulasService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 公式管理管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/eval/formulas")
public class FormulasController extends BaseController
{
    @Resource
    private IFormulasService formulasService;

    /**
     * 查询公式管理管理列表
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:list')")
    @GetMapping("/list")
    public TableDataInfo list(Formulas formulas)
    {
        startPage();
        List<Formulas> list = formulasService.selectFormulasList(formulas);
        return getDataTable(list);
    }

    /**
     * 导出公式管理管理列表
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:export')")
    @Log(title = "公式管理管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Formulas formulas)
    {
        List<Formulas> list = formulasService.selectFormulasList(formulas);
        ExcelUtil<Formulas> util = new ExcelUtil<Formulas>(Formulas.class);
        util.exportExcel(response, list, "公式管理管理数据");
    }

    /**
     * 获取公式管理管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(formulasService.selectFormulasById(id));
    }

    /**
     * 新增公式管理管理
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:add')")
    @Log(title = "公式管理管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Formulas formulas)
    {
        return toAjax(formulasService.insertFormulas(formulas));
    }

    /**
     * 修改公式管理管理
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:edit')")
    @Log(title = "公式管理管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Formulas formulas)
    {
        return toAjax(formulasService.updateFormulas(formulas));
    }

    /**
     * 删除公式管理管理
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:remove')")
    @Log(title = "公式管理管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(formulasService.deleteFormulasByIds(ids));
    }

    /**
     * 查看已维护公式
     * @param formulas
     * @return
     */
    @PreAuthorize("@ss.hasPermi('eval:formulas:info')")
    @Log(title = "公式管理管理", businessType = BusinessType.DELETE)
    @GetMapping("/infoList")
    public List<Formulas> findInfoList(Formulas formulas)
    {
        return formulasService.selectFormulasList(formulas);
    }
}
