yeg
2026-09-03 76cd5948e95ddbde9dd4411b466ee75ba20b562e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.ruoyi.web.controller.system;
 
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TTestWarningException;
import com.ruoyi.system.mapper.TTestMapper;
import com.ruoyi.system.service.ITTestService;
import com.ruoyi.system.service.impl.TestWarningExceptionService;
 
/** 测试预警异常查询与人工关闭接口。 */
@RestController
@RequestMapping("/system/test-warning-exceptions")
public class TTestWarningExceptionController extends BaseController {
    @Autowired private TTestMapper mapper;
    @Autowired private ITTestService testService;
    @Autowired private TestWarningExceptionService warningExceptionService;
    /** 按测试和状态查询后端异常事实。 */
    @PreAuthorize("@ss.hasPermi('system:exception:query')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required=false) Long testId, @RequestParam(required=false) String status) {
        startPage();
        List<TTestWarningException> rows = mapper.selectWarningExceptions(testId, status);
        return getDataTable(rows);
    }
    /** 校验测试负责人身份并关闭异常,同时追加测试审计事实。 */
    @PreAuthorize("@ss.hasPermi('system:exception:handle')")
    @Log(title = "测试预警异常", businessType = BusinessType.UPDATE)
    @PutMapping("/{exceptionId}/close")
    public AjaxResult close(@PathVariable Long exceptionId, @RequestBody CloseRequest request) {
        if (request == null || request.handlingNote() == null || request.handlingNote().trim().isEmpty()) return error("处理结果不能为空");
        TTestWarningException exception = mapper.selectWarningExceptionById(exceptionId);
        if (exception == null) return error("异常不存在");
        var test = testService.selectTestById(exception.getTestId());
        if (test == null || !getUserId().equals(test.getPrincipalId()))
            return error("仅测试负责人可以关闭预警异常");
        int rows = warningExceptionService.close(exceptionId, getUserId(), getUsername(), request.handlingNote().trim());
        return rows == 1 ? success(mapper.selectWarningExceptionById(exceptionId)) : error("异常已关闭或不存在");
    }
    public record CloseRequest(String handlingNote) {}
}