# activejdbc-spring-boot-starter **Repository Path**: leqixiaozi/activejdbc-spring-boot-starter ## Basic Information - **Project Name**: activejdbc-spring-boot-starter - **Description**: 运行时为你数据库的每一张表生成RESTful接口 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2024-10-11 - **Last Updated**: 2024-10-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # acivejdbc-spring-boot-starter ### 简介 该项目提供基于orm框架activejdbc的功能扩展。 项目将在springboot项目启动时、遍历容器中的数据源。 然后自动扫描数据库中每一张表的元数据 包括表名、主键、字段名、字段类型等。 在这个基础上使用JavaAssist字节码生成框架 动态生成所有必要的字节码并注入到容器中。 最终 本项目会为数据库的每一张表提供一套通用的CRUD接口: - 单条新增 - 单条修改 - 单条查询 - 单条删除 - 批量新增 - 批量修改 - 批量删除 - 分页查询 从而消除Java后端开发中重复性的简单接口开发工作。使后端开发者从重复性的开发任务中解放出来,专注与业务功能开发。 基于以上特性,该项目期望淘汰一些代码生成工具和插件。 ### 演示项目地址 * https://github.com/endlessworld/active-api * https://gitee.com/endlessvoid/active-api ### 引入方式 2021-10-06 1.0 版本正式发布到中央仓库 ``` cn.ipfs-files activejdbc-spring-boot-starter 1.0.1.RELEASE ``` ### 在线接口地址 * https://y29bdwkxrh.apifox.cn/api-62175699 # 整库通用数据接口 Base URLs: * 本地环境: http://127.0.0.1:9999 ## GET 分页查询 GET /model/{model-name} ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |isEqual|query|string| 否 |是否全等匹配,不填默认为false(true/false)| |order|query|string| 否 |分页参数-排序方式,与排序字段对应,多个以英文逗号隔开| |pageNum|query|string| 否 |分页参数-当前页码| |pageSize|query|string| 否 |分页参数-每页条数| |sort|query|string| 否 |分页参数-排序字段名,对应表结构必须包含该字段,多个以英文逗号隔开| > 返回示例 > 200 Response ```json { "code": 0, "data": { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ {} ], "total": 0 }, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## PUT 编辑 根据主键覆盖剩余字段 PUT /model/{model-name} > Body 请求参数 ```json "string" ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |body|body|string| 否 |none| > 返回示例 > 200 Response ```json { "code": 0, "data": {}, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Created|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## POST 新增 POST /model/{model-name} > Body 请求参数 ```json "string" ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |body|body|string| 否 |none| > 返回示例 > 200 Response ```json { "code": 0, "data": {}, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Created|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## DELETE 根据ID数组批量删除 DELETE /model/{model-name}/array ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |none| |id|query|integer| 是 |对应主键id| > 返回示例 > 200 Response ```json { "code": 0, "data": [ { "compositeKeys": [ "string" ], "frozen": true, "id": {}, "idName": "string", "longId": 0, "modified": true, "new": true, "valid": true } ], "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|No Content|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| ### 返回数据结构 ## PUT 批量新增或修改(有id则根据id修改,否则新增) PUT /model/{model-name}/batchCreateOrUpdate > Body 请求参数 ```json "string" ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |body|body|string| 否 |none| > 返回示例 > 200 Response ```json { "code": 0, "data": [ { "compositeKeys": [ "string" ], "frozen": true, "id": {}, "idName": "string", "longId": 0, "modified": true, "new": true, "valid": true } ], "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Created|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## POST 高级筛选 POST /model/{model-name}/filter > Body 请求参数 ```json { "columns": [ "string" ], "pageNum": 1, "pageSize": 10, "querys": [ [ { "name": "id", "operation": "EQUAL", "value": "1" } ] ], "sorter": [ { "direction": "ASC", "property": "id" } ], "view": {} } ``` ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |body|body|any| 否 |none| > 返回示例 > 200 Response ```json { "code": 0, "data": { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ { "property1": {}, "property2": {} } ], "total": 0 }, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Created|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## GET 加载符合条件的第一条 GET /model/{model-name}/findFirst ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| > 返回示例 > 200 Response ```json { "code": 0, "data": {}, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## GET 分页查询-并加载所有子表 GET /model/{model-name}/include ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |model-name|path|string| 是 |表名| |isEqual|query|string| 否 |是否全等匹配,不填默认为false(true/false)| |order|query|string| 否 |分页参数-排序方式,与排序字段对应,多个以英文逗号隔开| |pageNum|query|string| 否 |分页参数-当前页码| |pageSize|query|string| 否 |分页参数-每页条数| |sort|query|string| 否 |分页参数-排序字段名,对应表结构必须包含该字段,多个以英文逗号隔开| > 返回示例 > 200 Response ```json { "code": 0, "data": { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ {} ], "total": 0 }, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## GET 根据主键加载一条 GET /model/{model-name}/{id} ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |id|path|integer| 是 |对应主键id| |model-name|path|string| 是 |表名| > 返回示例 > 200 Response ```json { "code": 0, "data": {}, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Not Found|Inline| ### 返回数据结构 ## DELETE 根据主键逻辑删除 DELETE /model/{model-name}/{id} ### 请求参数 |名称|位置|类型|必选|说明| |---|---|---|---|---| |id|path|integer| 是 |对应主键id| |model-name|path|string| 是 |表名| > 返回示例 > 200 Response ```json { "code": 0, "data": {}, "message": "string" } ``` ### 返回结果 |状态码|状态码含义|说明|数据模型| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|Inline| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|No Content|Inline| |401|[Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1)|Unauthorized|Inline| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|Forbidden|Inline| ### 返回数据结构 # 数据模型

Response«PageQuery«Map«string,object»»»

```json { "code": 0, "data": { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ { "property1": {}, "property2": {} } ], "total": 0 }, "message": "string" } ``` Response«PageQuery«Map«string,object»»» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |code|integer(int32)|false|none||none| |data|[PageQuery«Map«string,object»»](#schemapagequery%c2%abmap%c2%abstring%2cobject%c2%bb%c2%bb)|false|none||none| |message|string|false|none||none|

PageQuery«Map«string,object»»

```json { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ { "property1": {}, "property2": {} } ], "total": 0 } ``` PageQuery«Map«string,object»» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |orderBys|string|false|none||none| |pageNum|integer(int32)|false|none||none| |pageSize|integer(int32)|false|none||none| |rows|[object]|false|none||none| |» **additionalProperties**|object|false|none||none| |total|integer(int64)|false|none||none|

QueryFilter«BaseModelVO»

```json { "columns": [ "string" ], "pageNum": 1, "pageSize": 10, "querys": [ [ { "name": "id", "operation": "EQUAL", "value": "1" } ] ], "sorter": [ { "direction": "ASC", "property": "id" } ], "view": {} } ``` QueryFilter«BaseModelVO» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |columns|[string]|false|none||返回字段| |pageNum|integer(int32)|false|none||页号| |pageSize|integer(int32)|false|none||分页大小| |querys|[array]|false|none||查询条件组,各条件组之间以and链接
同一组条件之间以or链接| |sorter|[[FieldSort](#schemafieldsort)]|false|none||字段排序| |view|[BaseModelVO](#schemabasemodelvo)|false|none||可作为查询参数的字段列表|

BaseModelVO

```json {} ``` BaseModelVO ### 属性 *None*

FieldSort

```json { "direction": "ASC", "property": "id" } ``` FieldSort ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |direction|string|false|none||排序方向| |property|string|false|none||排序字段| #### 枚举值 |属性|值| |---|---| |direction|ASC| |direction|DESC|

QueryField

```json { "name": "id", "operation": "EQUAL", "value": "1" } ``` QueryField ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |name|string|false|none||当前表包含的字段名| |operation|string|true|none||比较符
[EQUAL,等于,=]
[NOT_EQUAL: 不等于,!=]
[LESS: 小于,<]
[LESS_EQUAL: 小于等于,<=]
[GREAT: 大于,>]
[GREAT_EQUAL: 大于等于,>=]
[LIKE: 包含,like]
[NOT_LIKE: 不包含,not like]
[LEFT_LIKE: 以...开始,like]
[NOT_LEFT_LIKE: 不以...开始,not like]
[RIGHT_LIKE: 以...结束,like]
[NOT_RIGHT_LIKE: 不以...结束,not like]
[IS_NULL: 为null,is null]
[NOT_NULL: 不为null,is not null]
[IS_EMPTY: 空字符串, == '']
[NOT_EMPTY: 非空字符串,!= '']
[IN: 在...中,in]
[NOT_IN: 不在...中,not in]
[BETWEEN: 在...之间,between]
[NOT_BETWEEN: 不在...之间,not between]
[EQUAL_IGNORE_CASE: 等于忽略大小写,=]
[REGEXP: 正则表达式匹配,REGEXP]| |value|object|false|none||字段值: 数字,日期,字符串,数组 [1,2,3]/'value'/123/'2020-10-01'| #### 枚举值 |属性|值| |---|---| |operation|BETWEEN| |operation|EQUAL| |operation|EQUAL_IGNORE_CASE| |operation|GREAT| |operation|GREAT_EQUAL| |operation|IN| |operation|IS_EMPTY| |operation|IS_NULL| |operation|LEFT_LIKE| |operation|LESS| |operation|LESS_EQUAL| |operation|LIKE| |operation|NOT_BETWEEN| |operation|NOT_EMPTY| |operation|NOT_EQUAL| |operation|NOT_IN| |operation|NOT_LEFT_LIKE| |operation|NOT_LIKE| |operation|NOT_NULL| |operation|NOT_RIGHT_LIKE| |operation|REGEXP| |operation|RIGHT_LIKE|

Response«List«Model»»

```json { "code": 0, "data": [ { "compositeKeys": [ "string" ], "frozen": true, "id": {}, "idName": "string", "longId": 0, "modified": true, "new": true, "valid": true } ], "message": "string" } ``` Response«List«Model»» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |code|integer(int32)|false|none||none| |data|[[Model](#schemamodel)]|false|none||none| |message|string|false|none||none|

Model

```json { "compositeKeys": [ "string" ], "frozen": true, "id": {}, "idName": "string", "longId": 0, "modified": true, "new": true, "valid": true } ``` Model ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |compositeKeys|[string]|false|none||none| |frozen|boolean|false|none||none| |id|object|false|none||none| |idName|string|false|none||none| |longId|integer(int64)|false|none||none| |modified|boolean|false|none||none| |new|boolean|false|none||none| |valid|boolean|false|none||none|

Response«Map«string,object»»

```json { "code": 0, "data": {}, "message": "string" } ``` Response«Map«string,object»» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |code|integer(int32)|false|none||none| |data|object|false|none||none| |message|string|false|none||none|

Response«PageQuery»

```json { "code": 0, "data": { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ {} ], "total": 0 }, "message": "string" } ``` Response«PageQuery» ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |code|integer(int32)|false|none||none| |data|[PageQuery](#schemapagequery)|false|none||none| |message|string|false|none||none|

PageQuery

```json { "orderBys": "string", "pageNum": 0, "pageSize": 0, "rows": [ {} ], "total": 0 } ``` PageQuery ### 属性 |名称|类型|必选|约束|中文名|说明| |---|---|---|---|---|---| |orderBys|string|false|none||none| |pageNum|integer(int32)|false|none||none| |pageSize|integer(int32)|false|none||none| |rows|[object]|false|none||none| |total|integer(int64)|false|none||none|