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.qo.IDQO;
import com.test.test.domain.qo.TestReportAddQO;
import com.test.test.domain.vo.TestReportVo;
import com.test.test.service.ITestReportService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试报告Controller
 *
 * @author test
 * @date 2025-04-25
 */
@Slf4j
@RestController
@RequestMapping("/test/testReport")
public class TestReportController extends BaseController {

    @Autowired
    private ITestReportService testReportService;

    /**
     * 查询测试计划关联测试报告列表
     * @return
     */
    @PostMapping("/reportList")
    public TableDataInfo list(@RequestBody IDQO qo) {
        startPage();
        List<TestReportVo> list = testReportService.selectTestReportList(qo.getId());
        return getDataTable(list);
    }

    /**
     * 新增测试报告及关联测试计划
     * @param testReportAddQO
     * @return
     */
    @Log(title = "测试报告", businessType = BusinessType.INSERT)
    @PostMapping("/addTestReport")
    public AjaxResult addTestReport(@RequestBody TestReportAddQO testReportAddQO) {
        return toAjax(testReportService.addTestReport(testReportAddQO));
    }
}
