package com.cn.fdapfe.biz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cn.fdapfe.biz.domain.Data;
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.FaultDiagnosisModel;
import com.cn.fdapfe.biz.service.IFaultDiagnosisModelService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 故障诊断算法模型管理Controller
 * 
 * @author Allem
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/model/faultDiagnosis")
public class FaultDiagnosisModelController extends BaseController
{
    @Autowired
    private IFaultDiagnosisModelService faultDiagnosisModelService;

    /**
     * 查询故障诊断算法模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaultDiagnosisModel faultDiagnosisModel)
    {
        startPage();
        List<FaultDiagnosisModel> list = faultDiagnosisModelService.selectFaultDiagnosisModelList(faultDiagnosisModel);
        return getDataTable(list);
    }

    /**
     * 导出故障诊断算法模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:export')")
    @Log(title = "故障诊断算法模型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FaultDiagnosisModel faultDiagnosisModel)
    {
        List<FaultDiagnosisModel> list = faultDiagnosisModelService.selectFaultDiagnosisModelList(faultDiagnosisModel);
        ExcelUtil<FaultDiagnosisModel> util = new ExcelUtil<FaultDiagnosisModel>(FaultDiagnosisModel.class);
        util.exportExcel(response, list, "故障诊断算法模型管理数据");
    }

    /**
     * 获取故障诊断算法模型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(faultDiagnosisModelService.selectFaultDiagnosisModelById(id));
    }

    /**
     * 新增故障诊断算法模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:add')")
    @Log(title = "故障诊断算法模型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaultDiagnosisModel faultDiagnosisModel)
    {
        return toAjax(faultDiagnosisModelService.insertFaultDiagnosisModel(faultDiagnosisModel));
    }

    /**
     * 修改故障诊断算法模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:edit')")
    @Log(title = "故障诊断算法模型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaultDiagnosisModel faultDiagnosisModel)
    {
        return toAjax(faultDiagnosisModelService.updateFaultDiagnosisModel(faultDiagnosisModel));
    }

    /**
     * 删除故障诊断算法模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:remove')")
    @Log(title = "故障诊断算法模型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(faultDiagnosisModelService.deleteFaultDiagnosisModelByIds(ids));
    }

    /**
     * 查询故障诊断算法模型Options
     */
    @PreAuthorize("@ss.hasPermi('model:faultDiagnosis:list')")
    @GetMapping("/getOptions")
    public AjaxResult getOptions()
    {
        return success(faultDiagnosisModelService.getOptions());
    }
}
