# zeta-api
**Repository Path**: erupt/zeta-api
## Basic Information
- **Project Name**: zeta-api
- **Description**: 通过XML配置暴露Api接口,动态生成API文档
- **Primary Language**: Java
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 69
- **Forks**: 34
- **Created**: 2020-09-18
- **Last Updated**: 2025-06-13
## Categories & Tags
**Categories**: api-gateway
**Tags**: None
## README
# ZetaAPI
[](https://gitee.com/erupt/zeta-api)
[](https://github.com/erupts/zeta-api)
## 项目介绍
SQL + XML快速创建Api接口与使用文档,开发速度快如闪电!
## 框架特性
1. 配置简单功能丰富
2. 使用 xml 标签属性就可支持缓存,默认缓存实现为 caffeine,也可自定义缓存实现
3. 支持 if 标签分支判断,处理各种复杂场景
4. 自定义访问拦截,可创建拦截器修改表达式与返回结果
5. 根据 XML 配置,动态生成 Api 文档,支持在线测试
6. 支持xml热更新,无需重启容器,即可读取最新xml配置
7. 支持link标签,单次请求,执行多条SQL语句
8. 支持ip白名单配置
## 使用方法
1. 创建spring boot项目
2. 导入依赖
```xml
xyz.erupt
zeta-api
0.5.5
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-jdbc
```
3. 配置数据库连接与数据库驱动
4. 创建xml配置文件:/resources/epi/xxx.xml
5. xml文件示范例
``` xml
select 'hello world' key
select 'cache' cache,now() now
select :param param
select
'gt 10' param_status
'lt 10' param_status
'eq 10' param_status
insert into demo(content) values (:content)
select 'hi' hi
select now() now;
select '第二条SQL执行结果' result;
```
启动项目,查看接口文档:http://localhost:8080/zeta-doc/xml文件名.html
演示文档:http://localhost:8080/zeta-doc/$demo.html



## application.yml配置项说明
``` yaml
zeta-api:
#是否热读取xml配置,生产环境不要开启此功能
hotReadXml: true
#是否开始缓存功能
enableCache: true
#是否开启Api文档查询功能
enableApiDoc: true
#自定义缓存实现,需实现xyz.erupt.zeta_api.handler.ZetaCache接口
cacheHandlerPath: xyz.erupt.xxxx
#是否打印sql语句
showSql: true
#访问白名单,空表示不对ip进行鉴权
ipWhite:
- 127.0.0.1
- 192.168.1.1
- 192.168.1.187
```
## 接口请求示例
``` javascript
// jquery为例
$.ajax({
type: "POST",
url: "/zeta-api/sql/{file}/{name}",
contentType: "application/json", //请求内容需要为json
data: JSON.stringify({ param: 10}), //必须使用JSON.stringify
success: function (res) {
alert(res);
}
});
```
## 项目推荐
Erupt Framework 通用数据管理框架
仓库地址:https://github.com/erupts/erupt
官网地址:https://www.erupt.xyz