| | |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.battery.business.domain.TTestWarningException; |
| | | import com.battery.business.mapper.TTestMapper; |
| | | import com.battery.business.service.ITTestService; |
| | | import com.battery.business.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); |
| | | List<TTestWarningException> rows = warningExceptionService.list(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 AjaxResult close(@PathVariable Long exceptionId, @RequestBody(required=false) CloseRequest request) { |
| | | return success(warningExceptionService.closeByPrincipal(exceptionId, getUserId(), getUsername(), |
| | | request == null ? null : request.handlingNote())); |
| | | } |
| | | public record CloseRequest(String handlingNote) {} |
| | | } |