feat: 一些调整

This commit is contained in:
曹鹏飞 2025-02-15 22:15:32 +08:00
parent 5296aab048
commit 88bb491a55
5 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package com.nflg.mobilebroken.admin.controller;
import com.nflg.mobilebroken.starter.service.impl.APPSSEManagerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Collection;
/**
* 统计分析相关
*/
@RestController
@RequestMapping("/analysis")
public class AnalysisController extends ControllerBase{
@Resource
private APPSSEManagerService appSSEManagerService;
/**
* 获取当前已连接SSE的客户端用户列表
* @return 当前已连接SSE的客户端用户列表
*/
@GetMapping("getSSEConnects")
public Collection<Integer> getSSEConnects(){
return appSSEManagerService.getUserIds();
}
}

View File

@ -0,0 +1,29 @@
package com.nflg.mobilebroken.cfs.controller;
import com.nflg.mobilebroken.starter.service.impl.AdminSSEManagerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Collection;
/**
* 统计分析相关
*/
@RestController
@RequestMapping("/analysis")
public class AnalysisController extends ControllerBase{
@Resource
private AdminSSEManagerService adminSSEManagerService;
/**
* 获取当前已连接SSE的管理端用户列表
* @return 当前已连接SSE的管理端用户列表
*/
@GetMapping("getSSEConnects")
public Collection<Integer> getSSEConnects(){
return adminSSEManagerService.getUserIds();
}
}

View File

@ -4,6 +4,7 @@ import com.nflg.mobilebroken.common.pojo.dto.SSEMessageDTO;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
public interface SSEManagerService { public interface SSEManagerService {
@ -14,4 +15,6 @@ public interface SSEManagerService {
void close(Integer userId); void close(Integer userId);
void shutdown(); void shutdown();
Collection<Integer> getUserIds();
} }

View File

@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -47,4 +48,9 @@ public class APPSSEManagerService extends SSEManagerBase implements SSEManagerSe
public void shutdown() { public void shutdown() {
shutdown(EMITTERS); shutdown(EMITTERS);
} }
@Override
public Collection<Integer> getUserIds() {
return EMITTERS.keySet();
}
} }

View File

@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -47,4 +48,9 @@ public class AdminSSEManagerService extends SSEManagerBase implements SSEManager
public void shutdown() { public void shutdown() {
shutdown(EMITTERS); shutdown(EMITTERS);
} }
@Override
public Collection<Integer> getUserIds() {
return EMITTERS.keySet();
}
} }