package com.test.test.controller;

import com.test.common.annotation.Log;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.common.core.page.TableDataInfo;
import com.test.common.enums.BusinessType;
import com.test.test.domain.PerformanceTestCaseReport;
import com.test.test.service.IPerformanceTestCaseReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author liangdaliang
 * @Description：
 * @date 2025-04-14 16:59
 */
@RestController
@RequestMapping("/test/performanceReport")
public class PerformanceReportController extends BaseController {

    @Autowired
    private IPerformanceTestCaseReportService performanceTestCaseReportService;

    @GetMapping("/list")
    public TableDataInfo list(PerformanceTestCaseReport input)
    {
        startPage();
        input.setDelFlag("0");
        List<PerformanceTestCaseReport> list = performanceTestCaseReportService.selectPerformanceTestCaseReportList(input);
        return getDataTable(list);
    }

    /**
     * 获取单个性能测试报告详细信息
     */
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(performanceTestCaseReportService.selectPerformanceTestCaseReportById(id));
    }

    /**
     * 删除性能测试报告详细信息
     */
    @Log(title = "性能测试", businessType = BusinessType.UPDATE)
    @PutMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        PerformanceTestCaseReport report = performanceTestCaseReportService.selectPerformanceTestCaseReportById(id);
        if (report != null) {
            report.setDelFlag("1");
            report.setUpdateTime(new Date());
            return toAjax(performanceTestCaseReportService.updatePerformanceTestCaseReport(report));
        } else {
            return null;
        }
    }
}
