修改beta模块saveToDB接口问题
修改gamma模块saveToDB接口问题 修改beta模块saveToTXT,saveToExcel,saveToHtml问题
This commit is contained in:
parent
720e1bf975
commit
50787c22fe
|
@ -1,46 +0,0 @@
|
|||
package org.jeecg.modules.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sse")
|
||||
public class SSEController {
|
||||
private static Map<String, SseEmitter> sseCache = new ConcurrentHashMap<>();
|
||||
|
||||
@GetMapping("subscribe")
|
||||
public SseEmitter subscribe(String id) {
|
||||
// 超时时间设置为1小时
|
||||
SseEmitter sseEmitter = new SseEmitter(3600_000L);
|
||||
sseCache.put(id, sseEmitter);
|
||||
sseEmitter.onTimeout(() -> sseCache.remove(id));
|
||||
sseEmitter.onCompletion(() -> System.out.println("完成!!!"));
|
||||
return sseEmitter;
|
||||
}
|
||||
|
||||
@GetMapping("push")
|
||||
public String push(String id, String content) throws IOException {
|
||||
SseEmitter sseEmitter = sseCache.get(id);
|
||||
if (sseEmitter != null) {
|
||||
sseEmitter.send(content);
|
||||
}
|
||||
return "over";
|
||||
}
|
||||
|
||||
@GetMapping("over")
|
||||
public String over(String id) {
|
||||
SseEmitter sseEmitter = sseCache.get(id);
|
||||
if (sseEmitter != null) {
|
||||
sseEmitter.complete();
|
||||
sseCache.remove(id);
|
||||
}
|
||||
return "over";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user