package com.cn.fdapfe.biz.controller;

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.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.FdAlgorithm;
import com.cn.fdapfe.biz.service.IFdAlgorithmService;
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("/test/ddAlgorithm")
public class FdAlgorithmController extends BaseController
{
    @Autowired
    private IFdAlgorithmService fdAlgorithmService;

    /**
     * 查询故障诊断算法功能验证列表
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:list')")
    @GetMapping("/list")
    public TableDataInfo list(FdAlgorithm fdAlgorithm)
    {
        startPage();
        List<FdAlgorithm> list = fdAlgorithmService.selectFdAlgorithmList(fdAlgorithm);
        return getDataTable(list);
    }

    /**
     * 导出故障诊断算法功能验证列表
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:export')")
    @Log(title = "故障诊断算法功能验证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FdAlgorithm fdAlgorithm)
    {
        List<FdAlgorithm> list = fdAlgorithmService.selectFdAlgorithmList(fdAlgorithm);
        ExcelUtil<FdAlgorithm> util = new ExcelUtil<FdAlgorithm>(FdAlgorithm.class);
        util.exportExcel(response, list, "故障诊断算法功能验证数据");
    }

    /**
     * 获取故障诊断算法功能验证详细信息
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fdAlgorithmService.selectFdAlgorithmById(id));
    }

    /**
     * 新增故障诊断算法功能验证
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:add')")
    @Log(title = "故障诊断算法功能验证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FdAlgorithm fdAlgorithm)
    {
        return toAjax(fdAlgorithmService.insertFdAlgorithm(fdAlgorithm));
    }

    /**
     * 修改故障诊断算法功能验证
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:edit')")
    @Log(title = "故障诊断算法功能验证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FdAlgorithm fdAlgorithm)
    {
        return toAjax(fdAlgorithmService.updateFdAlgorithm(fdAlgorithm));
    }

    /**
     * 删除故障诊断算法功能验证
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:remove')")
    @Log(title = "故障诊断算法功能验证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fdAlgorithmService.deleteFdAlgorithmByIds(ids));
    }

    /**
     * 验证
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:edit')")
    @Log(title = "验证", businessType = BusinessType.UPDATE)
    @PutMapping("/handleVerify/{id}")
    public AjaxResult handleVerify(@PathVariable Long id)
    {
        return toAjax(fdAlgorithmService.handleVerify(id));
    }

    /**
     * 查询故障诊断算法功能验证Options
     */
    @PreAuthorize("@ss.hasPermi('test:ddAlgorithm:list')")
    @GetMapping("/getOptions")
    public AjaxResult getOptions()
    {
        return success(fdAlgorithmService.getOptions());
    }
}
