|
|
@@ -3,7 +3,9 @@ package com.telpo.dipperposition.controller; |
|
|
|
import com.alibaba.cloud.nacos.parser.NacosDataParserHandler; |
|
|
|
import com.alibaba.nacos.api.PropertyKeyConst; |
|
|
|
import com.alibaba.nacos.api.exception.NacosException; |
|
|
|
import com.telpo.dipperposition.co.RzlAccount; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
@@ -25,20 +27,24 @@ import com.alibaba.nacos.api.config.listener.Listener; |
|
|
|
@Slf4j |
|
|
|
public class DipperPositionController { |
|
|
|
|
|
|
|
@Autowired RzlAccount rzlAccount; |
|
|
|
|
|
|
|
@RequestMapping("/getPos") |
|
|
|
public String getPos() throws NacosException, InterruptedException, IOException { |
|
|
|
String group = "DEFAULT_GROUP"; |
|
|
|
String dataId = "dipperposition-service"; |
|
|
|
String positionId = "position.hello"; |
|
|
|
Properties properties = new Properties(); |
|
|
|
String serverAddr = "172.16.192.26"; |
|
|
|
properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); |
|
|
|
ConfigService configService = NacosFactory.createConfigService(properties); |
|
|
|
String content = configService.getConfig(dataId, group, 10000); |
|
|
|
System.out.println(content); |
|
|
|
//log.info(positionId + ":" + content.positionId) |
|
|
|
Map<String, Object> dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml"); |
|
|
|
return dataMap == null ? "" : (String)dataMap.get(positionId); |
|
|
|
// String group = "DEFAULT_GROUP"; |
|
|
|
// String dataId = "dipperposition-service"; |
|
|
|
// String positionId = "position.hello"; |
|
|
|
// Properties properties = new Properties(); |
|
|
|
// String serverAddr = "172.16.192.26"; |
|
|
|
// properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); |
|
|
|
// ConfigService configService = NacosFactory.createConfigService(properties); |
|
|
|
// String content = configService.getConfig(dataId, group, 10000); |
|
|
|
// System.out.println(content); |
|
|
|
// //log.info(positionId + ":" + content.positionId) |
|
|
|
// Map<String, Object> dataMap = NacosDataParserHandler.getInstance().parseNacosData(content,"yaml"); |
|
|
|
// return dataMap == null ? "" : (String)dataMap.get(positionId); |
|
|
|
|
|
|
|
return rzlAccount.getHello(); |
|
|
|
//return "Helle world!"; //ContextLoader.getCurrentWebApplicationContext().toString(); |
|
|
|
} |
|
|
|
} |