Skip to content

Commit

Permalink
fix(自动配置): SpringBoot的自动配置的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
lqyan committed Jul 24, 2024
1 parent 0ac882f commit 56b9683
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
4 changes: 2 additions & 2 deletions jhinno-openapi-java-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

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

<dependencies>
Expand Down
6 changes: 3 additions & 3 deletions jhinno-openapi-sdk-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

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


<dependencies>
<dependency>
<groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId>
<version>2.0.2</version>
<version>2.0.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
* openapi执行器自动配置
*
Expand All @@ -29,25 +26,58 @@ public class JHOpenapiExecutionAutoconfigure {
private final JHOpenapiProperties properties;
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
public JHAppApiExecution appApiExecution() {
JHAppApiExecution jhAppApiExecution = new JHAppApiExecution();
init(jhAppApiExecution);
return jhAppApiExecution;
}

@Bean
public JHDataApiExecution dataApiExecution() {
JHDataApiExecution dataApiExecution = new JHDataApiExecution();
init(dataApiExecution);
return dataApiExecution;
}


@Bean
public JHFileApiExecution fileApiExecution() {
JHFileApiExecution fileApiExecution = new JHFileApiExecution();
init(fileApiExecution);
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 List<JHApiExecution> ApiExecution() {
List<JHApiExecution> executions = new ArrayList<>();
executions.add(new JHAppApiExecution());
executions.add(new JHDataApiExecution());
executions.add(new JHFileApiExecution());
executions.add(new JHJobApiExecution());
executions.add(new JHDepartmentApiExecution());
executions.add(new JHUserApiExecution());
executions.forEach(t -> {
t.setJhApiClient(client);
t.setForceGetToken(properties.isForceGetToken());
t.setAuthType(properties.getAuthType());
t.setAccessKey(properties.getAccessKey());
t.setAccessKeySecret(properties.getAccessKeySecret());
t.setTokenTimeout(properties.getTokenTimeout());
t.setTokenResidueTime(properties.getTokenResidueTime());
t.setUsedServerTime(properties.isUsedServerTime());
});
return executions;
public JHUserApiExecution userApiExecution() {
JHUserApiExecution userApiExecution = new JHUserApiExecution();
init(userApiExecution);
return userApiExecution;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

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

0 comments on commit 56b9683

Please sign in to comment.