fix(自动配置): SpringBoot的自动配置的优化

This commit is contained in:
lqyan
2024-07-24 17:57:05 +08:00
parent 0ac882f645
commit 56b9683cf3
4 changed files with 58 additions and 28 deletions

View File

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-java-sdk</artifactId>
<version>2.0.2</version> <version>2.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Jhinno OpenAPI SDK for Java</name> <name>Jhinno OpenAPI SDK for Java</name>
<description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description> <description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description>
@@ -14,7 +14,7 @@
<parent> <parent>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk-parent</artifactId> <artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>1.0.2</version> <version>2.0.0</version>
</parent> </parent>
<dependencies> <dependencies>

View File

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>jhinno-openapi-sdk-spring-boot-starter</artifactId> <artifactId>jhinno-openapi-sdk-spring-boot-starter</artifactId>
<version>1.0.2</version> <version>2.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Jhinno OpenAPI SDK for Java SpringBoot Starter</name> <name>Jhinno OpenAPI SDK for Java SpringBoot Starter</name>
<description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description> <description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description>
@@ -14,7 +14,7 @@
<parent> <parent>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk-parent</artifactId> <artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>2.0.2</version> <version>2.0.0</version>
</parent> </parent>
@@ -22,7 +22,7 @@
<dependency> <dependency>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-java-sdk</artifactId>
<version>2.0.2</version> <version>2.0.0</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -12,9 +12,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
/** /**
* openapi执行器自动配置 * openapi执行器自动配置
* *
@@ -29,25 +26,58 @@ public class JHOpenapiExecutionAutoconfigure {
private final JHOpenapiProperties properties; private final JHOpenapiProperties properties;
private final JHApiClient client; private final JHApiClient client;
public void init(JHApiExecution apiExecution) {
apiExecution.setJhApiClient(client);
apiExecution.setForceGetToken(properties.isForceGetToken());
apiExecution.setAuthType(properties.getAuthType());
apiExecution.setAccessKey(properties.getAccessKey());
apiExecution.setAccessKeySecret(properties.getAccessKeySecret());
apiExecution.setTokenTimeout(properties.getTokenTimeout());
apiExecution.setTokenResidueTime(properties.getTokenResidueTime());
apiExecution.setUsedServerTime(properties.isUsedServerTime());
}
@Bean @Bean
public List<JHApiExecution> ApiExecution() { public JHAppApiExecution appApiExecution() {
List<JHApiExecution> executions = new ArrayList<>(); JHAppApiExecution jhAppApiExecution = new JHAppApiExecution();
executions.add(new JHAppApiExecution()); init(jhAppApiExecution);
executions.add(new JHDataApiExecution()); return jhAppApiExecution;
executions.add(new JHFileApiExecution()); }
executions.add(new JHJobApiExecution());
executions.add(new JHDepartmentApiExecution()); @Bean
executions.add(new JHUserApiExecution()); public JHDataApiExecution dataApiExecution() {
executions.forEach(t -> { JHDataApiExecution dataApiExecution = new JHDataApiExecution();
t.setJhApiClient(client); init(dataApiExecution);
t.setForceGetToken(properties.isForceGetToken()); return dataApiExecution;
t.setAuthType(properties.getAuthType()); }
t.setAccessKey(properties.getAccessKey());
t.setAccessKeySecret(properties.getAccessKeySecret());
t.setTokenTimeout(properties.getTokenTimeout()); @Bean
t.setTokenResidueTime(properties.getTokenResidueTime()); public JHFileApiExecution fileApiExecution() {
t.setUsedServerTime(properties.isUsedServerTime()); JHFileApiExecution fileApiExecution = new JHFileApiExecution();
}); init(fileApiExecution);
return executions; return fileApiExecution;
}
@Bean
public JHJobApiExecution jobApiExecution() {
JHJobApiExecution jobApiExecution = new JHJobApiExecution();
init(jobApiExecution);
return jobApiExecution;
}
@Bean
public JHDepartmentApiExecution departmentApiExecution() {
JHDepartmentApiExecution departmentApiExecution = new JHDepartmentApiExecution();
init(departmentApiExecution);
return departmentApiExecution;
}
@Bean
public JHUserApiExecution userApiExecution() {
JHUserApiExecution userApiExecution = new JHUserApiExecution();
init(userApiExecution);
return userApiExecution;
} }
} }

View File

@@ -6,7 +6,7 @@
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk-parent</artifactId> <artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>2.0.2</version> <version>2.0.0</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Jhinno OpenAPI SDK for Java parent</name> <name>Jhinno OpenAPI SDK for Java parent</name>
<description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description> <description>The Jhinno OpenAPI SDK for Java used for accessing Jhinno OpenApi Service</description>