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.PerformanceEvaluation;
import com.cn.fdapfe.biz.service.IPerformanceEvaluationService;
import com.cn.fdapfe.common.utils.poi.ExcelUtil;
import com.cn.fdapfe.common.core.page.TableDataInfo;

/**
 * 算法性能评估Controller
 * 
 * @author Allen
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/test/perf")
public class PerformanceEvaluationController extends BaseController
{
    @Autowired
    private IPerformanceEvaluationService performanceEvaluationService;

    /**
     * 查询算法性能评估列表
     */
    @PreAuthorize("@ss.hasPermi('test:perf:list')")
    @GetMapping("/list")
    public TableDataInfo list(PerformanceEvaluation performanceEvaluation)
    {
        startPage();
        List<PerformanceEvaluation> list = performanceEvaluationService.selectPerformanceEvaluationList(performanceEvaluation);
        return getDataTable(list);
    }

    /**
     * 导出算法性能评估列表
     */
    @PreAuthorize("@ss.hasPermi('test:perf:export')")
    @Log(title = "算法性能评估", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PerformanceEvaluation performanceEvaluation)
    {
        List<PerformanceEvaluation> list = performanceEvaluationService.selectPerformanceEvaluationList(performanceEvaluation);
        ExcelUtil<PerformanceEvaluation> util = new ExcelUtil<PerformanceEvaluation>(PerformanceEvaluation.class);
        util.exportExcel(response, list, "算法性能评估数据");
    }

    /**
     * 获取算法性能评估详细信息
     */
    @PreAuthorize("@ss.hasPermi('test:perf:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(performanceEvaluationService.selectPerformanceEvaluationById(id));
    }

    /**
     * 新增算法性能评估
     */
    @PreAuthorize("@ss.hasPermi('test:perf:add')")
    @Log(title = "算法性能评估", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PerformanceEvaluation performanceEvaluation)
    {
        return toAjax(performanceEvaluationService.insertPerformanceEvaluation(performanceEvaluation));
    }

    /**
     * 修改算法性能评估
     */
    @PreAuthorize("@ss.hasPermi('test:perf:edit')")
    @Log(title = "算法性能评估", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PerformanceEvaluation performanceEvaluation)
    {
        return toAjax(performanceEvaluationService.updatePerformanceEvaluation(performanceEvaluation));
    }

    /**
     * 删除算法性能评估
     */
    @PreAuthorize("@ss.hasPermi('test:perf:remove')")
    @Log(title = "算法性能评估", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(performanceEvaluationService.deletePerformanceEvaluationByIds(ids));
    }

    /**
     * 运行算法性能评估
     */
    @PreAuthorize("@ss.hasPermi('test:perf:edit')")
    @Log(title = "运行算法性能评估", businessType = BusinessType.UPDATE)
    @PutMapping("/run/{id}")
    public AjaxResult run(@PathVariable Long id)
    {
        return toAjax(performanceEvaluationService.run(id));
    }
}
