mirror of
https://github.com/yanlongqi/jhinno-openapi-java-sdk.git
synced 2026-03-22 06:15:10 +08:00
refactor: 重构API请求处理架构和用户管理
- 新增JHApiRequestHandler接口支持自定义请求头处理 - 重构JHApiExecutionAbstract为依赖注入提供更好支持 - 优化JHRequestExecution支持用户上下文管理 - 增强Spring Boot自动配置支持请求处理器注入 - 更新版本号至2.0.6 - 删除废弃的JHApiExecution类 - 修正测试类中的命名错误 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jhinno.sdk.openapi.autoconfigure;
|
||||
|
||||
import com.jhinno.sdk.openapi.JHApiRequestHandler;
|
||||
import com.jhinno.sdk.openapi.api.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.client.JHApiClient;
|
||||
import com.jhinno.sdk.openapi.client.JHApiHttpClientImpl;
|
||||
@@ -30,8 +31,15 @@ public class JHOpenapiClientAutoConfigure {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JHRequestExecution requestExecution(JHApiClient jhApiClient, JHOpenapiProperties properties) {
|
||||
JHRequestExecution requestExecution = new JHRequestExecution(jhApiClient);
|
||||
@ConditionalOnMissingBean
|
||||
public JHApiRequestHandler defaultRequestHandler() {
|
||||
return new JHApiRequestHandler() {
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JHRequestExecution requestExecution(JHApiClient jhApiClient, JHOpenapiProperties properties, JHApiRequestHandler requestHandler) {
|
||||
JHRequestExecution requestExecution = new JHRequestExecution(jhApiClient, requestHandler);
|
||||
requestExecution.setForceGetToken(properties.isForceGetToken());
|
||||
requestExecution.setAuthType(properties.getAuthType());
|
||||
requestExecution.setAccessKey(properties.getAccessKey());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.jhinno.sdk.openapi.autoconfigure;
|
||||
|
||||
import com.jhinno.sdk.openapi.JHApiExecution;
|
||||
import com.jhinno.sdk.openapi.JHApiExecutionAbstract;
|
||||
import com.jhinno.sdk.openapi.api.JHRequestExecution;
|
||||
import com.jhinno.sdk.openapi.api.app.JHAppApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.data.JHDataApiExecution;
|
||||
@@ -9,11 +9,14 @@ import com.jhinno.sdk.openapi.api.job.JHJobApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.organization.JHDepartmentApiExecution;
|
||||
import com.jhinno.sdk.openapi.api.organization.JHUserApiExecution;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* openapi执行器自动配置
|
||||
*
|
||||
@@ -26,39 +29,46 @@ public class JHOpenapiExecutionAutoconfigure implements BeanPostProcessor {
|
||||
|
||||
private final JHRequestExecution jhRequestExecution;
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||
if (bean instanceof JHApiExecution) {
|
||||
((JHApiExecution) bean).init(jhRequestExecution);
|
||||
if (bean instanceof JHApiExecutionAbstract) {
|
||||
((JHApiExecutionAbstract) bean).setExecution(jhRequestExecution);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHAppApiExecution appApiExecution() {
|
||||
return new JHAppApiExecution();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHDataApiExecution dataApiExecution() {
|
||||
return new JHDataApiExecution();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHFileApiExecution fileApiExecution() {
|
||||
return new JHFileApiExecution();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHJobApiExecution jobApiExecution() {
|
||||
return new JHJobApiExecution();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHDepartmentApiExecution departmentApiExecution() {
|
||||
return new JHDepartmentApiExecution();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public JHUserApiExecution userApiExecution() {
|
||||
return new JHUserApiExecution();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user