11 Commits

Author SHA1 Message Date
lqyan
646fb869dc fix(spring使用): 解决spring使用出现空指针异常的问题 2024-06-05 16:47:01 +08:00
lqyan
1dafc6dac8 Merge branch 'master' of github.com:yanlongqi/jhinno-openapi-java-sdk 2024-06-05 15:10:35 +08:00
lqyan
193e7b4fc2 doc(readme): 优化使用说明 2024-06-05 15:03:21 +08:00
lqyan
ec7d38f9dc doc(readme): 优化使用说明 2024-06-05 14:41:57 +08:00
燕陇琪
dda983c9e8 Merge branch 'bugfix' into 'master'
Bugfix

See merge request solutions/jhinno-openapi-java-sdk!2
2024-06-05 05:04:59 +00:00
yanlongqi
cb765320ab Merge pull request #5 from yanlongqi/bugfix
Bugfix:解决json在序列化的过程中有些字段不识别而报错的问题
2024-06-05 13:02:37 +08:00
lqyan
2ab5c20fb5 feat(数据序列化): 解决json在序列化的过程中有些字段不识别而报错的问题 2024-06-05 12:59:55 +08:00
lqyan
51c068c28d feat(数据序列化): 解决json在序列化的过程中有些字段不识别而报错的问题 2024-06-05 11:58:56 +08:00
燕陇琪
f3cb13703a Merge branch 'feat-20240604-springboot-starter' into 'master'
feat(新版发布): 开发Springboot-starter方便集成方调用,修复获取token本地时间和服务器时间有差异而导致的报错问题

See merge request solutions/jhinno-openapi-java-sdk!1
2024-06-05 03:31:45 +00:00
yanlongqi
78ff3feb90 Merge pull request #3 from yanlongqi/feat-20240604-springboot-starter
feat(新版发布): 开发Springboot-starter方便集成方调用,修复获取token本地时间和服务器时间有差异而导致的报错问题
2024-06-05 10:56:05 +08:00
lqyan
1ff758a31a feat(新版发布): 开发Springboot-starter方便集成方调用,修复获取token本地时间和服务器时间有差异而导致的报错问题 2024-06-05 10:48:43 +08:00
66 changed files with 839 additions and 237 deletions

5
.gitignore vendored
View File

@@ -4,10 +4,7 @@ target/
!**/src/test/**/target/ !**/src/test/**/target/
### IntelliJ IDEA ### ### IntelliJ IDEA ###
.idea/modules.xml .idea
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws *.iws
*.iml *.iml
*.ipr *.ipr

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SmartInputSourceJavaSceneConfigState">
<option name="customChineseScenes" value="{&quot;capsLockState&quot;:false,&quot;code&quot;:&quot;;ArgsException(errorMessage);setUserNameCn(userNameCn)&quot;,&quot;enable&quot;:true,&quot;languageType&quot;:&quot;CHINESE&quot;,&quot;name&quot;:&quot;自定义中文切换&quot;,&quot;tip&quot;:&quot;&quot;}" />
</component>
</project>

5
.idea/encodings.xml generated
View File

@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/jhinno-openapi-java-sdk/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jhinno-openapi-java-sdk/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jhinno-openapi-sdk-spring-boot-starter/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jhinno-openapi-sdk-spring-boot-starter/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component> </component>
</project> </project>

View File

@@ -1,8 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ADDITIONAL_TAGS" value="date" />
</inspection_tool>
</profile>
</component>

5
.idea/misc.xml generated
View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager"> <component name="MavenProjectsManager">
@@ -7,7 +8,5 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK" />
<output url="file://$PROJECT_DIR$/out" />
</component>
</project> </project>

2
.idea/vcs.xml generated
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>

217
README.md
View File

@@ -1,4 +1,4 @@
# Jhinno OpenAPI SDK for Java # 1. Jhinno OpenAPI SDK for Java
针对Java的景行API SDK使Java开发人员能够轻松使用景行API接口。您可以在几分钟内开始通过Maven或jar文件使用它。 针对Java的景行API SDK使Java开发人员能够轻松使用景行API接口。您可以在几分钟内开始通过Maven或jar文件使用它。
@@ -7,21 +7,26 @@
- [最新jar包jhinno-openapi-java-sdk-1.0.0.jar](https://jhinno-jenkins.yuchat.top/job/jhinno-openapi-java-sdk/lastSuccessfulBuild/artifact/target/jhinno-openapi-java-sdk-1.0.0.jar) - [最新jar包jhinno-openapi-java-sdk-1.0.0.jar](https://jhinno-jenkins.yuchat.top/job/jhinno-openapi-java-sdk/lastSuccessfulBuild/artifact/target/jhinno-openapi-java-sdk-1.0.0.jar)
- [最新源码包jhinno-openapi-java-sdk-1.0.0-sources.jar](https://jhinno-jenkins.yuchat.top/job/jhinno-openapi-java-sdk/lastSuccessfulBuild/artifact/target/jhinno-openapi-java-sdk-1.0.0-sources.jar) - [最新源码包jhinno-openapi-java-sdk-1.0.0-sources.jar](https://jhinno-jenkins.yuchat.top/job/jhinno-openapi-java-sdk/lastSuccessfulBuild/artifact/target/jhinno-openapi-java-sdk-1.0.0-sources.jar)
## 必要条件 ## 1.1 必要条件
- Java 1.8 or later - Java 1.8 or later
- Maven - Maven
## 支持的Appform的版本 ## 1.2 支持的Appform的版本
1. JH_Appform_6.0_Release 1. JH_Appform_6.0_Release
2. JH_Appform_6.0_SP1_Release 2. JH_Appform_6.0_SP1_Release
3. JH_Appform_6.1_Release
## 安装 # 2. 快速开始
建议在您的项目中使用Jhinno OpenAPI SDK for Java的方法是从Maven中使用它。导入方法如下 ## 2.1 SpringBoot
方法一通过Maven仓库安装 ### 2.1.1 安装
建议在您的项目中使用Jhinno OpenAPI SDK for Java的方法是从Maven中使用它。
#### 方法一通过Maven仓库安装
> 添加仓库地址改方案为备用方案后续会上传至Maven中央仓库目前不影响正常使用 > 添加仓库地址改方案为备用方案后续会上传至Maven中央仓库目前不影响正常使用
@@ -36,21 +41,113 @@
</repositories> </repositories>
``` ```
添加依赖 #### 方法二通过命令将jar包导入本地Maven仓库
```shell
# SDK Client的jar包的导入其中<path-to-dir>为jar的路径<path-to-dir>为jar包路径
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0-sources.jar"
# 例如
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="E:/下载/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="E:/下载/jhinno-openapi-java-sdk-1.0.0-sources.jar"
# SDK SpringBoot Starter的jar包的导入其中<path-to-dir>为jar的路径<path-to-dir>为jar包路径
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="<path-to-dir>/jhinno-openapi-sdk-spring-boot-starter-x.x.x.jar" -Dsources="<path-to-dir>/jhinno-openapi-sdk-spring-boot-starter-x.x.x-sources.jar"
# 例如
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="E:/下载/jhinno-openapi-sdk-spring-boot-starter-1.0.1.jar" -Dsources="E:/下载/jhinno-openapi-sdk-spring-boot-starter-1.0.1-sources.jar"
```
> 注:
> - jhinno-openapi-java-sdk-x.x.x.jar 为SDK的jar包。
> - jhinno-openapi-java-sdk-x.x.x-sources.jar 为源码包添加可方便查看SDK代码的注释。
> - jhinno-openapi-sdk-spring-boot-starter-x.x.x.jar 为SDK的spring-boot-starter的jar包。
> - jhinno-openapi-sdk-spring-boot-starter-1.0.1-sources.jar 为SDK的spring-boot-starter的源码包。
### 2.1.2 引入`jhinno-openapi-sdk-spring-boot-starter`坐标
```xml ```xml
<dependency> <dependency>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-sdk-spring-boot-starter</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
</dependency> </dependency>
``` ```
方法二通过命令将jar包导入本地Maven仓库 ### 2.1.3 配置
在SpringBoot的`application.properties``application.yml`里面配置
#### 2.1.3.1 application.yaml
```yaml
jhinno:
openapi:
server-url: https://{appform服务器的地址}/appform
used-server-time: true
```
#### 2.1.3.2 application.properties
```properties
jhinno.openapi.server-url=https://{appform服务器的地址}/appform
jhinno.openapi.used-server-time=true
```
> 注:
> - 其中`jhinno.openapi.server-url`为景行接口服务的BaseUrl
> - `jhinno.openapi.used-server-time`是否获取服务器时间来请求token关闭可提高获取token的时间但打开有可能因为服务器时间不准确而导致token获取失败的问题。
> - 更多配置见`com.jhinno.sdk.openapi.autoconfigure.JHOpenapiProperties`源码。
### 2.1.4 使用
`com.jhinno.sdk.openapi.api`包下面对应`app``data``file``job``organization`这几个子包,分别代表景行`Appform`
的应用、作业数据、文件、作业操作、组织等接口资源。开发者只需要使用接口的执行器(`JHxxxApiExecution`
)即可使用资源,如:`JHFileApiExecution`
```java
public class DemoUserSDK {
/**
* 注入要调用的执行器
*/
@Autowired
private JHFileApiExecution fileApiExecution;
void contextLoads() {
// 调用执行其中想要调用的方法
List<FileInfo> list = fileApiExecution.getFileList("jhadmin", "$HOME");
System.out.println(list);
}
}
```
## 2.2 Spring
### 2.2.1 安装
建议在您的项目中使用Jhinno OpenAPI SDK for Java的方法是从Maven中使用它。
#### 方法一通过Maven仓库安装
> 添加仓库地址改方案为备用方案后续会上传至Maven中央仓库目前不影响正常使用
```xml
<repositories>
<repository>
<id>jhinno-nexus</id>
<name>jhinno-nexus</name>
<url>https://jhinno-nexus.yuchat.top/repository/maven-releases</url>
</repository>
</repositories>
```
#### 方法二通过命令将jar包导入本地Maven仓库
```shell ```shell
# 其中<path-to-dir>为jar的路径<path-to-dir>为jar包路径
# SDK Client的jar包的导入其中<path-to-dir>为jar的路径<path-to-dir>为jar包路径
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0-sources.jar" mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="<path-to-dir>/jhinno-openapi-java-sdk-1.0.0-sources.jar"
# 例如 # 例如
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="E:/下载/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="E:/下载/jhinno-openapi-java-sdk-1.0.0-sources.jar" mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="E:/下载/jhinno-openapi-java-sdk-1.0.0.jar" -Dsources="E:/下载/jhinno-openapi-java-sdk-1.0.0-sources.jar"
@@ -60,44 +157,88 @@ mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile="E:/
> - jhinno-openapi-java-sdk-x.x.x.jar 为SDK的jar包。 > - jhinno-openapi-java-sdk-x.x.x.jar 为SDK的jar包。
> - jhinno-openapi-java-sdk-x.x.x-sources.jar 为源码包添加可方便查看SDK代码的注释。 > - jhinno-openapi-java-sdk-x.x.x-sources.jar 为源码包添加可方便查看SDK代码的注释。
然后在`pom.xml`添加 ### 2.2.2 引入`jhinno-openapi-java-sdk`坐标
```xml ```xml
<dependency> <dependency>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-java-sdk</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
</dependency> </dependency>
``` ```
方法三:直接在`pom.xml`引用jar(改方法可能会出现一些莫名其妙的问题,所以不建议使用) ### 2.2.3 配置
spring.xml添加以下内容
```xml ```xml
<!-- 其中{path-to-file}为jar的位置 --> <?xml version="1.0" encoding="utf-8"?>
<beans>
<bean id="apiClient" class="com.jhinno.sdk.openapi.client.JHApiClient">
<property name="baseUrl" value="https://172.17.0.5/appform"/>
</bean>
<bean id="appApiExecution" class="com.jhinno.sdk.openapi.api.app.JHAppApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
<bean id="dataApiExecution" class="com.jhinno.sdk.openapi.api.data.JHDataApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
<bean id="fileApiExecution" class="com.jhinno.sdk.openapi.api.file.JHFileApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
<bean id="jhJobApiExecution" class="com.jhinno.sdk.openapi.api.job.JHJobApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
<bean id="departmentApiExecution" class="com.jhinno.sdk.openapi.api.organization.JHDepartmentApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
<bean id="userApiExecution" class="com.jhinno.sdk.openapi.api.organization.JHUserApiExecution">
<constructor-arg ref="apiClient"/>
</bean>
</beans>
```
### 2.2.4 使用
`com.jhinno.sdk.openapi.api`包下面对应`app``data``file``job``organization`这几个子包,分别代表景行`Appform`
的应用、作业数据、文件、作业操作、组织等接口资源。开发者只需要使用接口的执行器(`JHxxxApiExecution`
)即可使用资源,如:`JHAppApiExecution`
```java
public class DemoUserSDK {
/**
* 注入要调用的执行器
*/
@Autowired
private JHFileApiExecution fileApiExecution;
void contextLoads() {
// 调用执行其中想要调用的方法
List<FileInfo> list = fileApiExecution.getFileList("jhadmin", "$HOME");
System.out.println(list);
}
}
```
## 2.3 普通java项目
### 2.3.1 安装
- 同 2.2.1 安装一样
### 2.3.2 引入`jhinno-openapi-java-sdk`坐标
```xml
<dependency> <dependency>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-java-sdk</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
<scope>system</scope>
<systemPath>{path-to-file}</systemPath>
</dependency> </dependency>
``` ```
### 2.3.3 使用
例如
```xml
<!-- 其中{path-to-file}为jar的位置 -->
<dependency>
<groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>D:/jar/jhinno-openapi-java-sdk-1.0.0.jar</systemPath>
</dependency>
```
## 使用
`com.jhinno.sdk.openapi.api`包下面对应`app``data``file``job``organization`这几个子包,分别代表景行`Appform` `com.jhinno.sdk.openapi.api`包下面对应`app``data``file``job``organization`这几个子包,分别代表景行`Appform`
的应用、作业数据、文件、作业操作、组织等接口资源。开发者只需要使用接口的执行器(`JHxxxApiExecution` 的应用、作业数据、文件、作业操作、组织等接口资源。开发者只需要使用接口的执行器(`JHxxxApiExecution`
@@ -137,7 +278,7 @@ public class DemoUserSDK {
``` ```
## 支持SDK的扩展 # 3. 支持SDK的扩展
如果是基于景行定制的接口本SDK没有包含这些方法因此您可以基于`JHApiExecution`快速进行扩展,具体的扩展步骤如下: 如果是基于景行定制的接口本SDK没有包含这些方法因此您可以基于`JHApiExecution`快速进行扩展,具体的扩展步骤如下:
@@ -170,7 +311,7 @@ public class JHAppApiExecution extends JHApiExecution {
``` ```
## 构建 # 4. 构建
一旦您检出代码就可以使用Maven构建它。使用以下命令进行构建 一旦您检出代码就可以使用Maven构建它。使用以下命令进行构建
@@ -178,17 +319,17 @@ public class JHAppApiExecution extends JHApiExecution {
mvn clean package -DskipTests -P product mvn clean package -DskipTests -P product
``` ```
## 代码贡献 # 5. 代码贡献
- 代码必须格式化使用IDEA自带的格式即可 - 代码必须格式化使用IDEA自带的格式即可
- 请求路径必须放在一个单独的const类中统一维护具体可参考现有代码提交 - 请求路径必须放在一个单独的const类中统一维护具体可参考现有代码提交
- 封装新的接口是需要继承`JHApiExecution`,调用父类的辅助方法辅助封装; - 封装新的接口是需要继承`JHApiExecution`,调用父类的辅助方法辅助封装;
## 作者 # 6. 作者
- [yanlongqi](https://github.com/yanlongqi) - [yanlongqi](https://github.com/yanlongqi)
## 支持 # 7. 支持
- 电话同微信18794888087 - 电话同微信18794888087
- 邮箱lqyan@jhinno.com - 邮箱lqyan@jhinno.com

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jhinno-openapi-java-sdk</artifactId>
<version>1.0.1</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>
<url>http://jhinno.com</url>
<parent>
<groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>1.0.1</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>jhinno-releases</id>
<url>http://192.168.87.22:8081/repository/maven-releases</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.0.0</version>
<configuration>
<encoding>UTF-8</encoding>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<sourcepath>target/generated-sources/delombok</sourcepath>
<encoding>${project.build.sourceEncoding}</encoding>
<docencoding>${project.build.sourceEncoding}</docencoding>
<charset>${project.build.sourceEncoding}</charset>
<doclint>none</doclint>
<tags>
<tag>
<name>date</name>
<placement>X</placement>
</tag>
</tags>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<developers>
<developer>
<id>lqyan</id>
<name>lqyan</name>
<email>lqyan@jhinno.com</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</project>

View File

@@ -1,7 +1,5 @@
package com.jhinno.sdk.openapi; package com.jhinno.sdk.openapi;
import org.omg.CosNaming.NamingContextPackage.NotFound;
/** /**
* 客户端错误相关常亮的定义 * 客户端错误相关常亮的定义
* *

View File

@@ -37,4 +37,9 @@ public class CommonConstant {
* 字符逗号 * 字符逗号
*/ */
public static final String NORMAL_CHARACTER_COMMA = ","; public static final String NORMAL_CHARACTER_COMMA = ",";
/**
* 是否使用服务器的时间
*/
public static final boolean DEFAULT_IS_USED_SERVER_TIME = false;
} }

View File

@@ -51,6 +51,12 @@ public class JHApiExecution {
private int tokenResidueTime = CommonConstant.DEFAULT_TOKEN_RESIDUE_TIME; private int tokenResidueTime = CommonConstant.DEFAULT_TOKEN_RESIDUE_TIME;
/**
* 是否使用服务器时间开启可能会导致请求过慢但是不会太慢默认token会有缓存
*/
private boolean isUsedServerTime = CommonConstant.DEFAULT_IS_USED_SERVER_TIME;
/** /**
* 获取一个执行器的实例 * 获取一个执行器的实例
* *
@@ -93,6 +99,23 @@ public class JHApiExecution {
this.tokenResidueTime = tokenResidueTime; this.tokenResidueTime = tokenResidueTime;
} }
/**
* 是否使用服务器时间
*/
public boolean isUsedServerTime() {
return isUsedServerTime;
}
/**
* 设置是否使用服务器时间
*
* @param usedServerTime 是否使用服务器时间
*/
public void setUsedServerTime(boolean usedServerTime) {
isUsedServerTime = usedServerTime;
}
/** /**
* 获取用户的Token * 获取用户的Token
* *
@@ -112,9 +135,9 @@ public class JHApiExecution {
if (isForce || tokenInfo == null || System.currentTimeMillis() - tokenInfo.getCurrentTimestamp() < tokenEffectiveTime) { if (isForce || tokenInfo == null || System.currentTimeMillis() - tokenInfo.getCurrentTimestamp() < tokenEffectiveTime) {
Map<String, Object> params = new HashMap<>(2); Map<String, Object> params = new HashMap<>(2);
params.put("timeout", tokenTimeout); params.put("timeout", tokenTimeout);
long currentTimeMillis = isUsedServerTime ? jhApiClient.requestTimeMillis() : System.currentTimeMillis();
AES aes = new AES(CommonConstant.DEFAULT_AES_KEY.getBytes()); AES aes = new AES(CommonConstant.DEFAULT_AES_KEY.getBytes());
String base64 = aes.encryptBase64(String.format("%s,%s", username, System.currentTimeMillis())); String base64 = aes.encryptBase64(String.format("%s,%s", username, currentTimeMillis));
params.put("username", base64); params.put("username", base64);
String url = JHApiClient.getUrl(AuthPathConstant.AUTH_TOKEN_PATH, params); String url = JHApiClient.getUrl(AuthPathConstant.AUTH_TOKEN_PATH, params);
Map<String, String> token = get(url, new TypeReference<ResponseResult<Map<String, String>>>() { Map<String, String> token = get(url, new TypeReference<ResponseResult<Map<String, String>>>() {

View File

@@ -24,5 +24,9 @@ public class AuthPathConstant {
*/ */
public static final String AUTH_REGISTER = "/ws/api/auth/register"; public static final String AUTH_REGISTER = "/ws/api/auth/register";
/**
* 测试服务器是否可用
*/
public static final String PING = "/ws/api/ping";
} }

View File

@@ -49,5 +49,10 @@ public class FileInfo {
*/ */
private Boolean execute; private Boolean execute;
/**
* 是否软连接
*/
private Boolean link;
} }

View File

@@ -20,17 +20,17 @@ public class DefaultHttpClientConfig {
/** /**
* 默认socket连接超时的时间(单位) * 默认socket连接超时的时间(单位)
*/ */
public static final int SOCKET_TIMEOUT = 5000; public static final int SOCKET_TIMEOUT = 5000;
/** /**
* 默认连接超时的时间(单位) * 默认连接超时的时间(单位)
*/ */
public static final int CONNECT_TIMEOUT = 5000; public static final int CONNECT_TIMEOUT = 5000;
/** /**
* 默认请求超时的时间(单位) * 默认请求超时的时间(单位)
*/ */
public static final int CONNECTION_REQUEST_TIMEOUT = 5000; public static final int CONNECTION_REQUEST_TIMEOUT = 5000;
} }

View File

@@ -3,11 +3,15 @@ package com.jhinno.sdk.openapi.client;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.jhinno.sdk.openapi.ArgsException; import com.jhinno.sdk.openapi.ArgsException;
import com.jhinno.sdk.openapi.ClientErrorCode; import com.jhinno.sdk.openapi.ClientErrorCode;
import com.jhinno.sdk.openapi.ClientException; import com.jhinno.sdk.openapi.ClientException;
import com.jhinno.sdk.openapi.api.auth.AuthPathConstant;
import lombok.Data;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
@@ -33,6 +37,7 @@ import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.KeyStoreException; import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
@@ -44,15 +49,16 @@ import java.util.TimeZone;
* @author yanlongqi * @author yanlongqi
* @date 2024/1/29 10:31 * @date 2024/1/29 10:31
*/ */
@Data
public class JHApiClient { public class JHApiClient {
/** /**
* 基础的请求URL地址 * &#x57FA;&#x7840;&#x7684;&#x8BF7;&#x6C42;URL&#x5730;&#x5740;
* <p> * <p>
* <a href="https://192.168.3.12/appform">https://192.168.3.12/appform</a> * &#x5982;&#xFF1A;https://192.168.3.12/appform
* </p> * </p>
*/ */
private final String baseUrl; private String baseUrl;
/** /**
@@ -60,26 +66,10 @@ public class JHApiClient {
*/ */
private ObjectMapper mapper; private ObjectMapper mapper;
/**
* 初始化一个JHApiClient的实例可使用自定义的客户端
*
* @param baseUrl 景行接口服务的基础地址
* @param closeableHttpClient 可关闭的HTTP客户端
*/
private JHApiClient(CloseableHttpClient closeableHttpClient, String baseUrl) {
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
this.closeableHttpClient = closeableHttpClient;
this.requestConfig = RequestConfig.custom().setSocketTimeout(DefaultHttpClientConfig.SOCKET_TIMEOUT).setConnectTimeout(DefaultHttpClientConfig.CONNECT_TIMEOUT).setConnectionRequestTimeout(DefaultHttpClientConfig.CONNECTION_REQUEST_TIMEOUT).build();
mapper = new ObjectMapper();
mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
mapper.setDateFormat(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN));
}
/** /**
* HTTP的连接客户端 * HTTP的连接客户端
*/ */
private final CloseableHttpClient closeableHttpClient; private CloseableHttpClient closeableHttpClient;
/** /**
@@ -87,28 +77,69 @@ public class JHApiClient {
*/ */
private RequestConfig requestConfig; private RequestConfig requestConfig;
private int socketTimeout = DefaultHttpClientConfig.SOCKET_TIMEOUT;
private int connectTimeout = DefaultHttpClientConfig.CONNECT_TIMEOUT;
private int connectRequestTimeout = DefaultHttpClientConfig.CONNECTION_REQUEST_TIMEOUT;
private int maxTotal = DefaultHttpClientConfig.MAX_TOTAL;
private int maxPerRout = DefaultHttpClientConfig.MAX_PER_ROUT;
/**
* 初始化一个JHApiClient的实例可使用自定义的客户端
*
* @param baseUrl 景行接口服务的基础地址
* @param closeableHttpClient 可关闭的HTTP客户端
*/
public JHApiClient(CloseableHttpClient closeableHttpClient, String baseUrl, int socketTimeout, int connectTimeout, int connectRequestTimeout) {
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.substring(0, baseUrl.length() - 1) : baseUrl;
this.closeableHttpClient = closeableHttpClient;
this.socketTimeout = socketTimeout;
this.connectTimeout = connectTimeout;
this.connectRequestTimeout = connectRequestTimeout;
clientInit();
}
public JHApiClient() {
closeableHttpClient = createHttpClients(maxTotal, maxPerRout);
clientInit();
}
/**
* 初始化客户端
*/
public void clientInit(){
this.requestConfig = RequestConfig.custom()
.setSocketTimeout(socketTimeout)
.setConnectTimeout(connectTimeout)
.setConnectionRequestTimeout(connectRequestTimeout)
.build();
mapper = new ObjectMapper();
mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
mapper.setDateFormat(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN));
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
/** /**
* 通过最大连接数和服务每次能并行接收的请求数量构建一个JHApiClient实例 * 通过最大连接数和服务每次能并行接收的请求数量构建一个JHApiClient实例
* *
* @param maxTotal 最大连接数 * @param maxTotal 最大连接数
* @param maxPerRout 服务每次能并行接收的请求数量 * @param maxPerRout 服务每次能并行接收的请求数量
* @param baseUrl 景行接口服务的基础地址 * @param baseUrl 景行接口服务的基础地址 : http://192.168.3.4/appform
* @return JHApiClient的实例 * @return JHApiClient的实例
*/ */
public static JHApiClient build(int maxTotal, int maxPerRout, String baseUrl) { public static JHApiClient build(String baseUrl, int maxTotal, int maxPerRout, int socketTimeout, int connectTimeout, int connectRequestTimeout) {
return build(createHttpClients(maxTotal, maxPerRout), baseUrl); return build(createHttpClients(maxTotal, maxPerRout), baseUrl, socketTimeout, connectTimeout, connectRequestTimeout);
} }
/** /**
* 通过{@link DefaultHttpClientConfig默认配置的最大连接数和服务每次能并行接收的请求数量构建一个JHApiClient实例 * 通过{@link DefaultHttpClientConfig默认配置的最大连接数和服务每次能并行接收的请求数量构建一个JHApiClient实例
* <p> * <p>
* *
* @param baseUrl 景行接口服务的基础地址 * @param baseUrl 景行接口服务的基础地址: http://192.168.3.4/appform
* @return JHApiClient的实例 * @return JHApiClient的实例
*/ */
public static JHApiClient build(String baseUrl) { public static JHApiClient build(String baseUrl) {
return build(createHttpClients(DefaultHttpClientConfig.MAX_TOTAL, DefaultHttpClientConfig.MAX_PER_ROUT), baseUrl); CloseableHttpClient client = createHttpClients(com.jhinno.sdk.openapi.client.DefaultHttpClientConfig.MAX_TOTAL, com.jhinno.sdk.openapi.client.DefaultHttpClientConfig.MAX_PER_ROUT);
return build(client, baseUrl, com.jhinno.sdk.openapi.client.DefaultHttpClientConfig.SOCKET_TIMEOUT, com.jhinno.sdk.openapi.client.DefaultHttpClientConfig.CONNECT_TIMEOUT, com.jhinno.sdk.openapi.client.DefaultHttpClientConfig.CONNECTION_REQUEST_TIMEOUT);
} }
/** /**
@@ -119,8 +150,8 @@ public class JHApiClient {
* @param baseUrl 景行接口服务的基础地址 * @param baseUrl 景行接口服务的基础地址
* @return JHApiClient的实例 * @return JHApiClient的实例
*/ */
public static JHApiClient build(CloseableHttpClient httpClient, String baseUrl) { public static JHApiClient build(CloseableHttpClient httpClient, String baseUrl, int socketTimeout, int connectTimeout, int connectRequestTimeout) {
return new JHApiClient(httpClient, baseUrl); return new JHApiClient(httpClient, baseUrl, socketTimeout, connectTimeout, connectRequestTimeout);
} }
@@ -226,6 +257,34 @@ public class JHApiClient {
} }
/**
* 请求服务器的时间戳
*
* @return 服务器的时间戳
*/
public Long requestTimeMillis() {
HttpGet httpGet = new HttpGet(getUrl(AuthPathConstant.PING));
httpGet.setConfig(requestConfig);
try {
HttpResponse response = closeableHttpClient.execute(httpGet);
Header header = response.getFirstHeader("Date");
if (header == null) {
return null;
}
String value = header.getValue();
if (StringUtils.isBlank(value)) {
return null;
}
return DatePattern.HTTP_DATETIME_FORMAT.parse(value).getTime();
} catch (IOException e) {
throw new ClientException(e.getMessage());
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
/** /**
* 发送请求 * 发送请求
* *

View File

@@ -13,6 +13,6 @@ public class JHClientConfig {
/** /**
* 初始化JHApi客户端 * 初始化JHApi客户端
*/ */
public static final JHApiClient client = JHApiClient.build("https://192.168.87.25/appform"); public static final JHApiClient client = JHApiClient.build("https://172.17.0.5/appform");
} }

View File

@@ -50,7 +50,7 @@ public class FileApiTest {
*/ */
@Test @Test
public void testGetFileList() { public void testGetFileList() {
List<FileInfo> fileList = execution.getFileList("lqyan", "$HOME"); List<FileInfo> fileList = execution.getFileList("jhadmin", "$HOME");
ConsoleTable consoleTable = ConsoleTable.create(); ConsoleTable consoleTable = ConsoleTable.create();
consoleTable.setSBCMode(false); consoleTable.setSBCMode(false);
consoleTable.addHeader("fileName", "fileType", "owner", "read", "write", "execute", "path"); consoleTable.addHeader("fileName", "fileType", "owner", "read", "write", "execute", "path");
@@ -65,7 +65,7 @@ public class FileApiTest {
*/ */
@Test @Test
public void testMkdir() { public void testMkdir() {
System.out.println(execution.mkdir("jhadmin", "$HOME/test", true)); System.out.println(execution.mkdir("jhadmin", "$HOMEtest1", true));
} }

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>jhinno-openapi-sdk-spring-boot-starter</artifactId>
<version>1.0.1</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>
<url>http://jhinno.com</url>
<parent>
<groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>1.0.1</version>
</parent>
<dependencies>
<dependency>
<groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>jhinno-releases</id>
<url>http://192.168.87.22:8081/repository/maven-releases</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.0.0</version>
<configuration>
<encoding>UTF-8</encoding>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<sourcepath>target/generated-sources/delombok</sourcepath>
<encoding>${project.build.sourceEncoding}</encoding>
<docencoding>${project.build.sourceEncoding}</docencoding>
<charset>${project.build.sourceEncoding}</charset>
<doclint>none</doclint>
<tags>
<tag>
<name>date</name>
<placement>X</placement>
</tag>
</tags>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<developers>
<developer>
<id>lqyan</id>
<name>lqyan</name>
<email>lqyan@jhinno.com</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</project>

View File

@@ -0,0 +1,32 @@
package com.jhinno.sdk.openapi.autoconfigure;
import com.jhinno.sdk.openapi.client.JHApiClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* openapi客户端自动配置
* @author yanlongqi
* @date 2024/6/4 16:01
*/
@Configuration
@EnableConfigurationProperties(JHOpenapiProperties.class)
public class JHOpenapiClientAutoConfigure {
@Bean
@ConditionalOnMissingBean
public JHApiClient jhApiClient(JHOpenapiProperties properties){
return JHApiClient.build(
properties.getServerUrl(),
properties.getMaxTotal(),
properties.getMaxPerRout(),
properties.getSocketTimeout(),
properties.getConnectTimeout(),
properties.getConnectRequestTimeout()
);
}
}

View File

@@ -0,0 +1,85 @@
package com.jhinno.sdk.openapi.autoconfigure;
import com.jhinno.sdk.openapi.api.JHApiExecution;
import com.jhinno.sdk.openapi.api.app.JHAppApiExecution;
import com.jhinno.sdk.openapi.api.data.JHDataApiExecution;
import com.jhinno.sdk.openapi.api.file.JHFileApiExecution;
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 com.jhinno.sdk.openapi.client.JHApiClient;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* openapi执行器自动配置
*
* @author yanlongqi
* @date 2024/6/4 17:27
*/
@Configuration
@RequiredArgsConstructor
public class JHOpenapiExecutionAutoconfigure {
private final JHOpenapiProperties properties;
private final JHApiClient client;
@Bean
public JHAppApiExecution appApiExecution() {
JHAppApiExecution execution = new JHAppApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
@Bean
public JHDataApiExecution dataApiExecution() {
JHDataApiExecution execution = new JHDataApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
@Bean
public JHFileApiExecution fileApiExecution() {
JHFileApiExecution execution = new JHFileApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
@Bean
public JHJobApiExecution jobApiExecution() {
JHJobApiExecution execution = new JHJobApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
@Bean
public JHDepartmentApiExecution departmentApiExecution() {
JHDepartmentApiExecution execution = new JHDepartmentApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
@Bean
public JHUserApiExecution userApiExecution() {
JHUserApiExecution execution = new JHUserApiExecution(client);
execution.setTokenTimeout(properties.getTokenTimeout());
execution.setTokenResidueTime(properties.getTokenResidueTime());
execution.setUsedServerTime(properties.isUsedServerTime());
return execution;
}
}

View File

@@ -0,0 +1,65 @@
package com.jhinno.sdk.openapi.autoconfigure;
import com.jhinno.sdk.openapi.CommonConstant;
import com.jhinno.sdk.openapi.client.DefaultHttpClientConfig;
import com.jhinno.sdk.openapi.constant.CommonConstants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @author yanlongqi
* @date 2024/6/4 16:03
*/
@Data
@ConfigurationProperties(prefix = CommonConstants.CONFIG_PREFIX)
public class JHOpenapiProperties {
/**
* 接口服务的BaseURL, 列如https://192.168.87.20/appform
*/
private String serverUrl;
/**
* 设置连接池的最大连接数,默认{@link DefaultHttpClientConfig#MAX_TOTAL}
*/
private int maxTotal = DefaultHttpClientConfig.MAX_TOTAL;
/**
* 设置服务每次能并行接收的请求数量,默认{@link DefaultHttpClientConfig#MAX_PER_ROUT}
*/
private int maxPerRout = DefaultHttpClientConfig.MAX_PER_ROUT;
/**
* 设置服务socket连接超时的时间(单位:毫秒),默认{@link DefaultHttpClientConfig#SOCKET_TIMEOUT}
*/
private int socketTimeout = DefaultHttpClientConfig.SOCKET_TIMEOUT;
/**
* 设置服务连接超时的时间(单位:毫秒),默认{@link DefaultHttpClientConfig#CONNECT_TIMEOUT}
*/
private int connectTimeout = DefaultHttpClientConfig.CONNECT_TIMEOUT;
/**
* 设置服务请求超时的时间(单位:毫秒),默认{@link DefaultHttpClientConfig#CONNECTION_REQUEST_TIMEOUT}
*/
private int connectRequestTimeout = DefaultHttpClientConfig.CONNECTION_REQUEST_TIMEOUT;
/**
* token的超时时间单位分钟
*/
private int tokenTimeout = CommonConstant.DEFAULT_TOKEN_EFFECTIVE_TIME;
/**
* token提前获取的时间单位分钟
*/
private int tokenResidueTime = CommonConstant.DEFAULT_TOKEN_RESIDUE_TIME;
/**
* 是否使用服务器时间
*/
private boolean usedServerTime = CommonConstant.DEFAULT_IS_USED_SERVER_TIME;
}

View File

@@ -0,0 +1,14 @@
package com.jhinno.sdk.openapi.constant;
/**
* @author yanlongqi
* @date 2024/6/4 16:12
*/
public class CommonConstants {
/**
* 配置的前缀
*/
public static final String CONFIG_PREFIX = "jhinno.openapi";
}

View File

@@ -0,0 +1,3 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.jhinno.sdk.openapi.autoconfigure.JHOpenapiClientAutoConfigure,\
com.jhinno.sdk.openapi.autoconfigure.JHOpenapiExecutionAutoconfigure

View File

@@ -0,0 +1,2 @@
com.jhinno.sdk.openapi.autoconfigure.JHOpenapiClientAutoConfigure
com.jhinno.sdk.openapi.autoconfigure.JHOpenapiExecutionAutoconfigure

143
pom.xml
View File

@@ -5,10 +5,10 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.jhinno</groupId> <groupId>com.jhinno</groupId>
<artifactId>jhinno-openapi-java-sdk</artifactId> <artifactId>jhinno-openapi-java-sdk-parent</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
<packaging>jar</packaging> <packaging>pom</packaging>
<name>Jhinno OpenAPI SDK for Java</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>
<url>http://jhinno.com</url> <url>http://jhinno.com</url>
@@ -21,70 +21,12 @@
<maven.test.skip>true</maven.test.skip> <maven.test.skip>true</maven.test.skip>
</properties> </properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement> <distributionManagement>
<repository> <repository>
@@ -93,70 +35,11 @@
</repository> </repository>
</distributionManagement> </distributionManagement>
<build> <modules>
<plugins> <module>jhinno-openapi-java-sdk</module>
<plugin> <module>jhinno-openapi-sdk-spring-boot-starter</module>
<groupId>org.apache.maven.plugins</groupId> </modules>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.0.0</version>
<configuration>
<encoding>UTF-8</encoding>
<sourceDirectory>src/main/java</sourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<sourcepath>target/generated-sources/delombok</sourcepath>
<encoding>${project.build.sourceEncoding}</encoding>
<docencoding>${project.build.sourceEncoding}</docencoding>
<charset>${project.build.sourceEncoding}</charset>
<doclint>none</doclint>
<tags>
<tag>
<name>date</name>
<placement>X</placement>
</tag>
</tags>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<developers> <developers>
<developer> <developer>