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.TestPlanCase;
import com.test.test.domain.qo.TestPlanCaseQO;
import com.test.test.service.ITestPlanCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 测试计划用例关联Controller
 *
 * @author test
 * @date 2025-04-25
 */
@RestController
@RequestMapping("/test/planCase")
public class TestPlanCaseController extends BaseController
{
    @Autowired
    private ITestPlanCaseService testPlanCaseService;

    /**
     * 查询测试计划用例关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TestPlanCase testPlanCase)
    {
        startPage();
        List<TestPlanCase> list = testPlanCaseService.selectTestPlanCaseList(testPlanCase);
        return getDataTable(list);
    }

    /**
     * 导出测试计划用例关联列表
     */
//    @Log(title = "测试计划用例关联", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, TestPlanCase testPlanCase)
//    {
//        List<TestPlanCase> list = testPlanCaseService.selectTestPlanCaseList(testPlanCase);
//        ExcelUtil<TestPlanCase> util = new ExcelUtil<TestPlanCase>(TestPlanCase.class);
//        util.exportExcel(response, list, "测试计划用例关联数据");
//    }

    /**
     * 获取测试计划用例关联详细信息
     */
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(testPlanCaseService.selectTestPlanCaseById(id));
//    }

    /**
     * 新增测试计划用例关联
     */
    @Log(title = "测试计划用例关联", businessType = BusinessType.INSERT)
    @PostMapping(value = "/saveRelate")
    public AjaxResult saveRelate(@RequestBody TestPlanCaseQO qo)
    {
        testPlanCaseService.saveRelate(qo);
        return success(qo);
    }

    /**
     * 修改测试计划用例关联
     */
//    @Log(title = "测试计划用例关联", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody TestPlanCase testPlanCase)
//    {
//        return toAjax(testPlanCaseService.updateTestPlanCase(testPlanCase));
//    }

    /**
     * 删除测试计划用例关联
     */
    @Log(title = "测试计划用例关联", businessType = BusinessType.DELETE)
    @PostMapping("/delRelate/{ids}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids)
    {
        return toAjax(testPlanCaseService.deleteTestPlanCaseByIds(ids));
    }
}
