腾讯 APIJSON 4.6.6+ 的字段插件,支持 字段名映射 和 !key 反选字段,可通过 Maven, Gradle 等远程依赖。
A column plugin for Tencent APIJSON 4.6.6+ , support Column Inverse and Column Mapping.
添加依赖
Add Dependency
Maven
1. 在 pom.xml 中添加 JitPack 仓库
1. Add the JitPack repository to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
2. 在 pom.xml 中添加 apijson-column 依赖
2. Add the apijson-column dependency to pom.xml
<dependency>
<groupId>com.github.APIJSON</groupId>
<artifactId>apijson-column</artifactId>
<version>LATEST</version>
</dependency>
Gradle
1. 在项目根目录 build.gradle 中最后添加 JitPack 仓库
1. Add the JitPack repository in your root build.gradle at the end of repositories
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
app
) build.gradle 中添加 apijson-column 依赖
2. 在项目某个 module 目录(例如 app
)
2. Add the apijson-column dependency in one of your modules(such as dependencies {
implementation 'com.github.APIJSON:apijson-column:latest'
}
初始化
Initialization
见 ColumnUtil 的注释及 APIJSONBoot 的 DemoSQLConfig 和 DemoSQLExecutor
See document in ColumnUtil and DemoSQLConfig, DemoSQLExecutor in APIJSONBoot
使用
Usage
1.反选字段
1.Column Inverse
"@column": "!columnKey" // 返回排除 columnKey 后的全部其它字段
"@column": "!columnKey" // return all columns except for columnKey
{
"User": { // id,sex,name,tag,head,contactIdList,pictureList,date
"id": 82001,
"@column": "!contactIdList" // -> id,sex,name,tag,head,pictureList,date
}
}
2.字段名映射
2.Column Mapping
"@column": "showKey" // 隐藏了数据库的对应真实字段名
"@column": "showKey" // the real column name is hidden
{
"User": { // id,sex,name,tag,head,contactIdList,pictureList,date
"id": 82001,
"@column": "gender" // -> sex
}
}
注意:APIAuto 不能自动获取并展示对应映射字段 showKey 的类型、长度、注释等文档,只能通过手写注释来实现
Note: APIAuto cannot automatically get and show the document for the showKey, you can add comment manually.