mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 14:25:11 +08:00
feat(示例): 增加SpringBoot示例以及SDK扩展逻辑的优化
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.jhinno.sdk.openapi.example;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ExampleApplication {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExampleApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jhinno.sdk.openapi.example.api.extend;
|
||||
|
||||
public enum FileEnvType {
|
||||
|
||||
HOME_ENV{
|
||||
@Override
|
||||
public String getEnv() {
|
||||
return "home";
|
||||
}
|
||||
},
|
||||
SPOOLER_ENV{
|
||||
@Override
|
||||
public String getEnv() {
|
||||
return "spooler";
|
||||
}
|
||||
};
|
||||
|
||||
public abstract String getEnv();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.jhinno.sdk.openapi.example.api.extend;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FilePath {
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.jhinno.sdk.openapi.example.api.extend;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum FileSystemType {
|
||||
|
||||
SYSTEM_TYPE_LINUX {
|
||||
@Override
|
||||
public String getType() {
|
||||
return "linux";
|
||||
}
|
||||
},
|
||||
SYSTEM_TYPE_WINDOWS {
|
||||
@Override
|
||||
public String getType() {
|
||||
return "windows";
|
||||
}
|
||||
};
|
||||
|
||||
public abstract String getType();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jhinno.sdk.openapi.example.api.extend;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.jhinno.sdk.openapi.api.JHApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.ResponseResult;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JHFileApiExtendExecution extends JHApiExecution {
|
||||
|
||||
public static String GET_FILE_ENV_PATH = "/ws/api/files/path/{env}";
|
||||
|
||||
public FilePath getFileEnvPath(String username, FileEnvType env, FileSystemType type) {
|
||||
Map<String, Object> params = new HashMap<>(1);
|
||||
if (StringUtils.isNotBlank(type.getType())) {
|
||||
params.put("type", type.getType());
|
||||
}
|
||||
String url = JHApiClient.getUrl(GET_FILE_ENV_PATH.replace("{env}", env.getEnv()), params);
|
||||
return get(url, username, new TypeReference<ResponseResult<FilePath>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public FilePath getFileHomeEnvPath(String username, FileSystemType type) {
|
||||
return getFileEnvPath(username, FileEnvType.HOME_ENV, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jhinno.sdk.openapi.example.config;
|
||||
|
||||
import com.jhinno.sdk.openapi.example.api.extend.JHFileApiExtendExecution;
|
||||
import com.jhinno.sdk.openapi.utils.JHOpenApiConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class JHOpenapiExecutionConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public JHFileApiExtendExecution fileApiExtendExecution(JHOpenApiConfig jhOpenApiConfig) {
|
||||
return jhOpenApiConfig.configJHApiExecution(new JHFileApiExtendExecution());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
jhinno:
|
||||
openapi:
|
||||
server-url: https://172.17.0.5/appform
|
||||
auth-type: access_secret_mode
|
||||
access-key: 3f03747f147942bd8debd81b6c9c6a80
|
||||
access-key-secret: e0681859b91c499eb1d2c8e09cea3242
|
||||
Reference in New Issue
Block a user