增加api相关配置
This commit is contained in:
parent
7dcfabf503
commit
b459f66925
|
|
@ -0,0 +1,24 @@
|
|||
package org.jetlinks.community.standalone.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ConfigurationProperties(prefix = "api")
|
||||
@Component
|
||||
public class ApiInfoProperties {
|
||||
|
||||
@Schema(description = "api根路径")
|
||||
private String basePath;
|
||||
|
||||
@Schema(description = "api地址信息")
|
||||
private Map<String, String> urls = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +1,54 @@
|
|||
package org.jetlinks.community.standalone.web;
|
||||
|
||||
import org.hswebframework.web.authorization.annotation.Authorize;
|
||||
import org.jetlinks.community.Version;
|
||||
import lombok.Getter;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/system")
|
||||
@RestController
|
||||
public class SystemInfoController {
|
||||
|
||||
@GetMapping("/version")
|
||||
@Authorize(ignore = true)
|
||||
public Mono<Version> getVersion() {
|
||||
return Mono.just(Version.current);
|
||||
private static final Map<String, Object> versionResponse;
|
||||
|
||||
private final ApiInfoProperties infoProperties;
|
||||
|
||||
static {
|
||||
versionResponse = new HashMap<>();
|
||||
versionResponse.put("result", new Version());
|
||||
versionResponse.put("status", 200);
|
||||
versionResponse.put("code", "success");
|
||||
}
|
||||
|
||||
public SystemInfoController(ApiInfoProperties infoProperties) {
|
||||
this.infoProperties = infoProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/version")
|
||||
public Mono<Map<String, Object>> getVersion() {
|
||||
|
||||
return Mono.just(versionResponse);
|
||||
}
|
||||
|
||||
@GetMapping("/apis")
|
||||
public Mono<Map<String, Object>> getApis() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("result", infoProperties);
|
||||
map.put("status", 200);
|
||||
map.put("code", "success");
|
||||
return Mono.just(map);
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class Version {
|
||||
private final String edition = "pro";
|
||||
private final String version = "1.1.0-SNAPSHOT";
|
||||
private final String mode = "cloud";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ hsweb:
|
|||
file:
|
||||
manager:
|
||||
storage-base-path: ./data/files
|
||||
api:
|
||||
# 访问系统接口的根地址
|
||||
base-path: http://127.0.0.1:${server.port}
|
||||
|
||||
jetlinks:
|
||||
server-id: ${spring.application.name}:${server.port} #设备服务网关服务ID,不同服务请设置不同的ID
|
||||
|
|
|
|||
Loading…
Reference in New Issue