yeg
2026-09-07 eee00fd63f558cfa0caf737c868de8fc0c652fcd
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
package com.battery.business.web;
 
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.battery.business.service.ITestLiveService;
 
/** 测试控制台实时 REST/SSE 入口,仅负责鉴权和协议转发。 */
@RestController
@RequestMapping("/system/test")
public class TTestLiveController extends BaseController
{
    private final ITestLiveService liveService;
    private final TestLiveStream stream;
    public TTestLiveController(ITestLiveService liveService, TestLiveStream stream)
    { this.liveService = liveService; this.stream = stream; }
 
    @PreAuthorize("@ss.hasPermi('system:test:query')")
    @GetMapping("/{testId}/live-state")
    public AjaxResult liveState(@PathVariable Long testId) { return success(liveService.current(testId)); }
 
    /** 推送实时快照、设备状态和可追溯的异常事实。 */
    @PreAuthorize("@ss.hasPermi('system:test:query')")
    @GetMapping(value = "/{testId}/live", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public SseEmitter live(@PathVariable Long testId) { return stream.stream(testId); }
}