♻️ Refactoring code. 去除 nacos 登录警告提示
This commit is contained in:
1 parent
8f355d8c30
commit
9458a3f3b3
1 file changed
+19
-23
+19
-23
@@ -16,19 +16,16 @@
|
||||
|
||||
package com.alibaba.nacos.console.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import com.alibaba.nacos.common.model.RestResult;
|
||||
import com.alibaba.nacos.common.model.RestResultUtils;
|
||||
import com.alibaba.nacos.sys.module.ModuleState;
|
||||
import com.alibaba.nacos.sys.module.ModuleStateHolder;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,26 +38,25 @@ import java.util.Map;
|
||||
@RequestMapping("/v1/console/server")
|
||||
public class ServerStateController {
|
||||
|
||||
private static final String ANNOUNCEMENT_FILE = "conf/announcement.conf";
|
||||
private static final String ANNOUNCEMENT_FILE = "classpath:conf/announcement.conf";
|
||||
|
||||
/**
|
||||
* Get server state of current server.
|
||||
*
|
||||
* @return state json.
|
||||
*/
|
||||
@GetMapping("/state")
|
||||
public ResponseEntity<Map<String, String>> serverState() {
|
||||
Map<String, String> serverState = new HashMap<>(4);
|
||||
for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) {
|
||||
each.getStates().forEach((s, o) -> serverState.put(s, null == o ? null : o.toString()));
|
||||
}
|
||||
return ResponseEntity.ok().body(serverState);
|
||||
}
|
||||
/**
|
||||
* Get server state of current server.
|
||||
* @return state json.
|
||||
*/
|
||||
@GetMapping("/state")
|
||||
public ResponseEntity<Map<String, String>> serverState() {
|
||||
Map<String, String> serverState = new HashMap<>(4);
|
||||
for (ModuleState each : ModuleStateHolder.getInstance().getAllModuleStates()) {
|
||||
each.getStates().forEach((s, o) -> serverState.put(s, null == o ? null : o.toString()));
|
||||
}
|
||||
return ResponseEntity.ok().body(serverState);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/announcement")
|
||||
public RestResult<String> getAnnouncement() {
|
||||
return RestResultUtils.success();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@GetMapping("/announcement")
|
||||
public RestResult<String> getAnnouncement() {
|
||||
ClassPathResource resource = new ClassPathResource(ANNOUNCEMENT_FILE);
|
||||
return RestResultUtils.success(FileUtil.readString(resource.getFile(), Charset.defaultCharset()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user