mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
feat(sdk): 项目使用优化和代码的优化
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cim.jhinno</groupId>
|
||||
<artifactId>jhinno-openapi-sdk-spring-boot-example</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<version>2.0.4</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Jhinno OpenAPI SDK for Java SpringBoot Example</name>
|
||||
<description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description>
|
||||
@@ -22,7 +22,7 @@
|
||||
<dependency>
|
||||
<groupId>com.jhinno</groupId>
|
||||
<artifactId>jhinno-openapi-sdk-spring-boot-starter</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
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.JHApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.api.ResponseResult;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JHFileApiExtendExecution extends JHApiExecution {
|
||||
@Component
|
||||
public class JHFileApiExtendExecution implements JHApiExecution {
|
||||
|
||||
private JHRequestExecution execution;
|
||||
|
||||
@Override
|
||||
public void init(JHRequestExecution execution) {
|
||||
this.execution = execution;
|
||||
}
|
||||
|
||||
public static String GET_FILE_ENV_PATH = "/ws/api/files/path/{env}";
|
||||
|
||||
@@ -19,11 +29,12 @@ public class JHFileApiExtendExecution extends JHApiExecution {
|
||||
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>>() {
|
||||
return execution.get(url, username, new TypeReference<ResponseResult<FilePath>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public FilePath getFileHomeEnvPath(String username, FileSystemType type) {
|
||||
return getFileEnvPath(username, FileEnvType.HOME_ENV, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
jhinno:
|
||||
openapi:
|
||||
server-url: https://172.17.0.5/appform
|
||||
auth-type: access_secret_mode
|
||||
server-url: https://192.168.87.24/appform
|
||||
auth-type: token_mode
|
||||
access-key: 3f03747f147942bd8debd81b6c9c6a80
|
||||
access-key-secret: e0681859b91c499eb1d2c8e09cea3242
|
||||
@@ -5,6 +5,7 @@ import com.jhinno.sdk.openapi.example.api.extend.JHFileApiExtendExecution;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import com.jhinno.sdk.openapi.api.app.JHAppApiExecution;
|
||||
|
||||
@SpringBootTest
|
||||
public class JHFileApiExtendTest {
|
||||
@@ -12,8 +13,17 @@ public class JHFileApiExtendTest {
|
||||
@Autowired
|
||||
private JHFileApiExtendExecution jhFileApiExtendExecution;
|
||||
|
||||
@Autowired
|
||||
private JHAppApiExecution jhAppApiExecution;
|
||||
|
||||
@Test
|
||||
void testGetFileHomeEnvPath() {
|
||||
System.out.println(jhFileApiExtendExecution.getFileHomeEnvPath("jhadmin", FileSystemType.SYSTEM_TYPE_LINUX));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testStartApp() {
|
||||
jhAppApiExecution.desktopStart("jhadmin","linux_desktop");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user