feat(sdk): 项目使用优化和代码的优化

This commit is contained in:
lqyan
2025-02-20 17:24:52 +08:00
parent 9ae5d9acd2
commit 72f508c14f
29 changed files with 443 additions and 372 deletions

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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

View File

@@ -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");
}
}