REQ-2411: 读取nacos配置
This commit is contained in:
parent
dd8c27d87f
commit
fdeae8937b
@ -10,10 +10,13 @@ import cn.axzo.msg.center.inside.notices.service.impl.v3.MessageRecordServiceV3;
|
|||||||
import cn.axzo.msg.center.message.domain.param.PendingMessagePushParam;
|
import cn.axzo.msg.center.message.domain.param.PendingMessagePushParam;
|
||||||
import cn.axzo.msg.center.message.service.group.GroupTemplateService;
|
import cn.axzo.msg.center.message.service.group.GroupTemplateService;
|
||||||
import cn.axzo.msg.center.message.service.todo.manage.TodoManager;
|
import cn.axzo.msg.center.message.service.todo.manage.TodoManager;
|
||||||
|
import com.alibaba.cloud.nacos.NacosConfigManager;
|
||||||
|
import com.alibaba.cloud.nacos.parser.NacosDataParserHandler;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.core.env.PropertySource;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -39,6 +42,7 @@ public class PrivateMessageController {
|
|||||||
private final TodoSearchService todoSearchService;
|
private final TodoSearchService todoSearchService;
|
||||||
private final TodoManager todoManager;
|
private final TodoManager todoManager;
|
||||||
private final GroupTemplateService groupTemplateService;
|
private final GroupTemplateService groupTemplateService;
|
||||||
|
private final NacosConfigManager nacosConfigManager;
|
||||||
|
|
||||||
@PostMapping("/sendPendingMessage")
|
@PostMapping("/sendPendingMessage")
|
||||||
public Object sendPendingMessage(@RequestBody @Valid PendingMessagePushParam request) {
|
public Object sendPendingMessage(@RequestBody @Valid PendingMessagePushParam request) {
|
||||||
@ -87,4 +91,20 @@ public class PrivateMessageController {
|
|||||||
}
|
}
|
||||||
return phone2PersonId;
|
return phone2PersonId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 因为没有权限了, 用于查看nacos是否配置了正确的值
|
||||||
|
*/
|
||||||
|
@PostMapping("/readNacosConfig")
|
||||||
|
public Object readNacosConfig() throws Exception {
|
||||||
|
String value = nacosConfigManager.getConfigService()
|
||||||
|
.getConfig("msg-center.yaml", "DEFAULT_GROUP", 5000);
|
||||||
|
List<PropertySource<?>> sources = NacosDataParserHandler.getInstance()
|
||||||
|
.parseNacosData("msg-center.yaml", value, "yaml");
|
||||||
|
if (sources == null) return null;
|
||||||
|
return sources.stream()
|
||||||
|
.map(PropertySource::getSource)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user