# OpenUtil
**Repository Path**: FnTop/openutil
## Basic Information
- **Project Name**: OpenUtil
- **Description**: 一个轻量级企业接口封装SDK,以简单的方式提供接口给外部调用
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: http://openutil.fntop.cn/
- **GVP Project**: No
## Statistics
- **Stars**: 3
- **Forks**: 1
- **Created**: 2023-08-03
- **Last Updated**: 2023-11-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: spring-boot-starter
## README
# 介绍
对外接口快速封装的 `spring boot starter`,这个`starter`是为了方便将对外接口进行快速封装并提供给外部调用。
以注解方式进行快速封装,外部以`方法api`的方式调用,摒弃传统对接方封装httpclient工具的繁琐流程,加快对接速度。框架支持丰富的自定义扩展。
* [官方文档](http://openutil.fntop.cn/)
* [Api文档](https://apidoc.gitee.com/FnTop/openutil)
* [使用案例](https://gitee.com/FnTop/fn-sms)
开源不易,大家帮忙点个`start`支持下
# 特点
* 快:对外接口封装快,外部对接速度快
* 新:对外接口文档新写法(面向方法api的接口文档)
* 丰富的自定义扩展
* 多业务分类处理
* 自定义序列化策略
* 支持多线程
* 支持拦截器
* 支持代理
## 版本说明
| version | spring boot version | java version |
|:-------:|:-------------------:|:------------:|
| 2.0.2 | 2.6.2 | 1.8 |
## Maven
```xml
cn.fntop
open-api-spring-boot-starter
2.0.2
```
## Gradle
```
//方式1
implementation 'cn.fntop:open-api-spring-boot-starter:2.0.2'
//方式2
implementation group: 'cn.fntop', name: 'open-api-spring-boot-starter', version: '2.0.2'
```
# 配置提示

# 配置
```yaml
fn:
#接口网关,域名+your-context,如果没有context就不用加context,尾部一定要加上`/`
open-gateway: http://xxx.com/your-context/
#代理
proxy-domain: xxx
proxy-port: xxx
```
## 配置说明
| 配置项 | 默认值 | 说明 |
|:-----------------------------|:-----------------------------|:------------------------------------------|
| fn.open-gateway | http://xxx.com/your-context/ | 接口调用网关,默认http://127.0.0.1:8080/。末尾一定要加"/" |
| fn.proxy-domain | 127.0.0.1 | 代理主机 |
| fn.proxy-port | 38672 | 代理端口 |
# 默认方法Api `OpenApiService`
添加依赖项后注入`OpenApiService`即可
```java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class Demo {
private final OpenApiService openApiService;
}
//或者
@Service
public class Demo {
@Autowired
private OpenApiService openApiService;
public Object method1(){
//参数为接口地址
openApiService.get("hello/custom");
}
}
```
# 自定义扩展
1. 自定义配置
```java
@Configuration
@RequiredArgsConstructor
public class CustomConfig {
private final OpenApiProperties properties;
@Bean
public CustomOpenApiService customOpenApiService() {
return (CustomOpenApiService) CustomOpenApiService.getInstance(properties, CustomOpenApi.class, CustomOpenApiService.class);
}
}
```
2. 自定义开放接口 `extends OpenApi`
```java
public interface CustomOpenApi extends OpenApi {
@GET("hello/custom")
Single