package com.gkhy.safePlatform.controller; import com.alibaba.nacos.api.exception.NacosException; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.service.WebsocketServerNamingService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = "/ws/namesrv") public class WebsocketNamingServiceController { @Value("${websocket.server.safecheck}") private String serverName; @Autowired private WebsocketServerNamingService websocketServerNamingService; @GetMapping("/get/list") public Object getSelfServiceList() throws NacosException { ResultVO resultVO = websocketServerNamingService.listHealthyInstance(serverName); return resultVO; } @GetMapping("/get/one") public Object getSelfServiceOne(String srv) throws NacosException { ResultVO resultVO = new ResultVO<>(); resultVO.setCode(ResultCodes.OK.getCode()); if(srv == null || srv.isEmpty()){ return resultVO; } if(srv.equals(serverName)){ resultVO = websocketServerNamingService.getOneHealthyInstance(serverName); } return resultVO; } }