package com.cn.fdapfe.biz.controller;

import java.util.List;
import javax.annotation.Resource;
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.FaultPhysicalModel;
import com.cn.fdapfe.biz.service.IFaultPhysicalModelService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 故障物理模型管理Controller
 * 
 * @author Allen
 * @date 2025-03-07
 */
@RestController
@RequestMapping("/model/faultPhysical")
public class FaultPhysicalModelController extends BaseController
{
    @Resource
    private IFaultPhysicalModelService faultPhysicalModelService;

    /**
     * 查询故障物理模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:list')")
    @GetMapping("/list")
    public TableDataInfo list(FaultPhysicalModel faultPhysicalModel)
    {
        startPage();
        List<FaultPhysicalModel> list = faultPhysicalModelService.selectFaultPhysicalModelList(faultPhysicalModel);
        return getDataTable(list);
    }

    /**
     * 导出故障物理模型管理列表
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:export')")
    @Log(title = "故障物理模型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FaultPhysicalModel faultPhysicalModel)
    {
        List<FaultPhysicalModel> list = faultPhysicalModelService.selectFaultPhysicalModelList(faultPhysicalModel);
        ExcelUtil<FaultPhysicalModel> util = new ExcelUtil<FaultPhysicalModel>(FaultPhysicalModel.class);
        util.exportExcel(response, list, "故障物理模型管理数据");
    }

    /**
     * 获取故障物理模型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(faultPhysicalModelService.selectFaultPhysicalModelById(id));
    }

    /**
     * 新增故障物理模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:add')")
    @Log(title = "故障物理模型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FaultPhysicalModel faultPhysicalModel)
    {
        return toAjax(faultPhysicalModelService.insertFaultPhysicalModel(faultPhysicalModel));
    }

    /**
     * 修改故障物理模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:edit')")
    @Log(title = "故障物理模型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FaultPhysicalModel faultPhysicalModel)
    {
        return toAjax(faultPhysicalModelService.updateFaultPhysicalModel(faultPhysicalModel));
    }

    /**
     * 删除故障物理模型管理
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:remove')")
    @Log(title = "故障物理模型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public void remove(@PathVariable String[] ids)
    {
        faultPhysicalModelService.deleteFaultPhysicalModelByIds(ids);
    }

    /**
     * 查询故障物理模型Options
     */
    @PreAuthorize("@ss.hasPermi('model:faultPhysical:list')")
    @GetMapping("/getOptions")
    public AjaxResult getOptions(String typs)
    {
        return success(faultPhysicalModelService.getOptions(typs));
    }
}
