APIJSON Documentation

Real-Time no-code, powerful and secure ORM 🚀 providing APIs and Docs without coding by Backend, and Frontend(Client) can customize response JSONs 🏆 实时...

18,397 stars Java Java 1 file · ~18,208 tokens #baas#clickhouse#crud#databricks#elasticsearch#hadoop#hive#influxdb
RAW Doc

1. Project Overview & Quickstart (Tencent/APIJSON)

File: README.md

APIJSON


  • [1.About](#1)

  • [2.Backend usage](#2)

  • [3.Frontend usage](#3)

  • [4.Contributing](#4)

  • [5.Releases](#5)

  • [6.Creator](#6)

  • [7.Donating](#7)

1. About

APIJSON is a JSON based internet communication protocol and an ORM library
that largely simplifies the process of back-end API development.
It also allows users to get data more quickly with self-defined form and fewer endpoints requests.

Features:

For getting data:

You can get any data by defining the specific information you want and send it to the server.
You can get different types of data by making just one request to the server.
It's very convenient and flexible, and dosen't require different API endpoints with multiple requests.
It provides CRUD(read and write), Fuzzy Search, Remote Function Calls, etc.
You can also save duplicate data, see request history, etc.

For API design:

APIJSON largely reduces API developers' workload by reducing most api design and documentation work.
With APIJSON, client developers will no longer be suffered from possible errors in documents,
and it saves communication between server developers and client developers about APIs or documentations.
Server developers no longer need to worry about compatibility of APIs and documents with legacy apps.

Song Firework-Katy Parry(Modified for APIJSON)

Do you ever feel like a backend slave
Repeating CRUD, wanting to make a change?
Do you ever feel, APIs' so paper thin
Like a house of cards, one blow from cavin' in?
Do you ever feel they always complain?
Urging doc and feedback bugs, even ask your refactoring
Do you know that there's still a chance for you?
'Cause there's a powerful tool
You just gotta depend and configure
And let it init
Just start APIs
They are so easy to try
'Cause baby, you're a firework
Come on, show 'em what you're worth
Make 'em go, "Oh, oh, oh"
As you give 'em an A-T-M
Baby, you're a firework
Come on, let them serve themselves
Make 'em go, "Oh, oh, oh"
You're gonna leave 'em all in awe, awe, awe.

Tired with endless arguments about HTTP API dev or use?
Use APIJSON-the ORM for providing infinity codeless CRUD APIs that fit almost all your needs.
Unfold the Power(In Your Soul) with ⭐ Star & Clone.

APIJSON Show

Postman test APIJSON

APIAuto test APIJSON

Note: The UI is APIAuto, the URL+JSON is APIJSON

2.Backend usage [](https://jitpack.io/#APIJSON/APIJSON)

You can skip this step and use 'apijson.cn:8080'.
See https://github.com/APIJSON/APIJSON-Demo/blob/master/APIJSON-Java-Server/README-English.md

Maven

1. Add the JitPack repository to pom.xml

xml
<repositories>
		<repository>
		    jitpack.io
		    https://jitpack.io
		</repository>
	</repositories>

2. Add the APIJSON dependency to pom.xml

xml
<dependency>
	    <groupId>com.github.APIJSON</groupId>
	    <artifactId>APIJSON</artifactId>
	    <version>latest</version>
	</dependency>

Gradle

1. Add the JitPack repository in your root build.gradle at the end of repositories

gradle
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

2. Add the APIJSON dependency in one of your modules(such as `app`)

gradle
dependencies {
	        implementation 'com.github.APIJSON:APIJSON:latest'
	}

3. Frontend usage

You can skip this step and use APIAuto or download App.
See Android, iOS or JavaScript

Download App

Simple demo App for testing APIJSON
APIJSONTest.apk

Complex production App like Twitter tweets
APIJSONApp.apk

4. Contributing

We are always looking for more developers to help implementing new features, fix bugs, etc.
Please have a look at the open issues before opening a new one.

Fork the project and send a pull request.

Please also ⭐ Star(on the top right) this project!

5. Releases

See the latest release here

6. Creator

https://github.com/TommyLemon

If you have any questions or suggestions, you can create an issue or send me an e-mail.

Users of APIJSON:

issues/187

More APIJSON Users

Contributers of APIJSON:

Contributers for the APIJSON core project(7 Tencent engineers, 1 Microsoft engineer, 1 Zhihu architect, 1 Bytedance(TikTok) engineer, 1 NetEase engineer, 1 Zoom engineer, 1 YTO Express engineer, 1 Zhilian engineer, 1 UC student、3 SUSTech students, etc.):

Authors of other projects for ecosystem of APIJSON(2 Tencent engineers, 1 BAT(Baidu/Alibaba/Tencent) expert, 1 Microsoft engineer, 2 Bytedance(TikTok) engineers, 1 Digital China engineer & Apache dubbo2js author, etc.):
https://github.com/search?o=desc&q=apijson&s=stars&type=Repositories
https://search.gitee.com/?skin=rec&type=repository&q=apijson&sort=stars_count

Tencent Security, Ant Group Sourcebrella, QAX CodeSafe submitted security reports(Issue)



Thanks to all contributers of APIJSON!

Statistics

Hundreds of employees from big famous companies(Tencent, Google, Apple, Microsoft, Amazon, Huawei, Alibaba, Paypal, Meituan, Bytedance(TikTok), IBM, Baidu, JD, NetEase, Kuaishou, Shopee, etc.) starred,
a lot of employees from big famous companies(Tencent, Huawei, Microsoft, Zoom, etc.) created PR/Issue, thank you all~

APIJSON was shown as a top open source Java projects on OSS Compass #518

Ecosystem

APIJSON-Demo Demo projects with document and SQL files for APIJSON with different programming languages and different frameworks

A2API AI generate UI once, API view/edit data everytime safely, quickly and stably. Chat agent to HTTP API to safely, quickly and stably add, view, edit or remove data in tables, forms or charts together with A2UI.

apijson-orm APIJSON ORM library, Maven, Gradle, etc can be used for dependencies

apijson-framework APIJSON Server Framework for configuring access of roles and validation of arguments in database tables, then using APIJSON easier

apijson-router A router plugin for APIJSON, expose undercontrolled RESTful-like HTTP API to public network, transfer to APIJSON request and execute

apijson-column A column plugin for APIJSON, supports Column Inverse and Column Mapping

apijson-jackson A jackson plugin for APIJSON

apijson-fastjson2 A fastjson2 plugin for APIJSON

apijson-gson A gson plugin for APIJSON

apijson-milvus An APIJSON plugin for Milvus - An AI vector database

apijson-influxdb An APIJSON plugin for InfluxDB - An IoT time-series database

apijson-mongodb An APIJSON plugin for MongoDB - A NoSQL database

apijson-cassandra An APIJSON plugin for Cassandra - A NoSQL database

APIAuto ☔ The most advanced tool for HTTP API. Machine learning no-code testing and AI assistant, generating codes and static analysis, generating comments and floating hints. Used by Tencent, SHEIN, TRANSSION, etc

CVAuto 👁 No-code, zero-annotation CV(Computer Vision) AI automated testing tool 🚀 Eliminates the need for extensive manual tasks such as drawing bounding boxes and labeling for image recognition algorithms

UnitAuto ☀️ The most advanced unit testing way powered by machine learning. Coding-free, comprehensive and automatic testing for methods/functions. Used by Tencent, Kwai, a Fortune 500 company, etc

SQLAuto 🔍 A smart SQL testing automation tool for databases, supports any CRUD, any template variables, generating argument combinations, generating lots of data rows

UIGO 📱 Coding-free, fast, accurate and stable UI replayer 🚀 Incredible ±3px auto locating and ±2ms auto waiting. Used by Tencent, invited by WeChat team to share

APIJSONdocs APIJSON English documentation, provided a website to view

apijson-doc APIJSON Chinese documentation, provided a website to view

apijson.org APIJSON official website

APIJSON.NET APIJSON for C#, supports CRUD for MySQL, PostgreSQL, SQL Server, Oracle, SQLite

apijson-go APIJSON for Go, based on Go(>=1.18) + GoFrame2, support CRUD

apijson-go APIJSON for Go, support CRUD, can directly run in Docker

apijson-hyperf APIJSON for PHP, based on Hyperf, supports MySQL

APIJSON-php APIJSON for PHP, based on ThinkPHP,supports MySQL, PostgreSQL, SQL Server, Oracle, etc

apijson-php APIJSON for PHP, based on ThinkPHP,supports MySQL, PostgreSQL, SQL Server, Oracle, etc

apijson-node APIJSON for Node.js, developed by a ByteDance engineer, provides demos for NestJS and Typeorm, as well as backend management

nestjs-apijson APIJSON for NestJS, supports CRUD, Joins for MySQL, PostgreSQL, SQLite (AI assisted)

uliweb-apijson APIJSON for Python, supports CRUD for MySQL, PostgreSQL, SQL Server, Oracle, SQLite, etc

apijson-rust APIJSON for Rust, supports CRUD for MySQL and PostgreSQL (AI assisted)

APIJSONParser An APIJSON Parser, dynamically parses JSON to SQL

FfApiJson An APIJSON Parser, parses JSON to SQL, supports multiple data sources

APIJSON-ToDo-Demo A simple TODO demo for APIJSON with customized authorization and authentication

apijson-learn APIJSON study note and analysis for source code

apijson-practice A library for APIJSON parameter validation annotations and related demos, open-sourced by a BAT expert

apijson-db2 Demo of APIJSON + IBM DB2 database, open-sourced by a Microsoft engineer

APIJSONDemo Demo of APIJSON + ClickHouse database, open-sourced by a ByteDance engineer

APIJSONDemo_ClickHouse Demo for APIJSON + SpringBoot + ClickHouse

APIJSONBoot_Hive Demo for APIJSON + SpringBoot + Hive

apijson-sample Simple demo and tutorial for using APIJSON

apijson-examples Demo for APIJSON with frontend web page, backend server and management system

apijson-ruoyi APIJSON + RuoYi, provides online maintenance for database configuration, etc

light4j Demo for APIJSON + Redis + light-4j - a microservices framework

SpringServer1.2-APIJSON The smart Party building server provides interfaces for uploading and downloading files

apijson_template APIJSON Java template, using Gradle to manage dependencie and building apps

api-json-demo Demo for APIJSON to replace traditional ORM, compated Oracle transactions

ApiJsonByJFinal Demo for APIJSON + JFinal - a popular web framework

bookmark Online bookmark using goframe + apijson-go + vue3 + antd vue 4

apijson-go-demo Demo for apijson-go

apijson-go-ui apijson-go UI config, supports access control, request rule configuration, etc

apijson-builder A JavaScript client library providing RESTful-like functions for APIJSON

AbsGrade List cascading algorithm supports single-level comments in WeChat Moments, double-level comments in QQ Space, and multi-level (unlimited-level) folders in Baidu Cloud

APIJSON-Android-RxJava Practical project mimicking WeChat Moments updates, based on ZBLibrary(UI) + APIJSON(HTTP) + RxJava(Data)

Android-ZBLibrary 🔥 An Android MVP Framework with many demos, detailed documents, simple usages and strict codes

apijson-dynamic-datasource Based on APIJSON, this demo demonstrates dynamic data source switching and batch operations on the same data source to ensure transaction consistency

xyerp Low-code ERP based on APIJSON

quick-boot Low-code system based on Spring Cloud 2022 + Spring Boot 3 + AMIS + APIJSON

apijson-query-spring-boot-starter A plugin for quickly building APIJSON query conditions

apijson-builder A simplified TypeScript wrapper for APIJSON, easier to remember than directly constructing query JSON

lanmuc A platform for producing low-code backend APIs, compatible with both configuration-based and code-based APIs, enabling rapid API production and project deployment

review_plan Review Reminder Web Version (Java Technology Practice Project)

apijson-nutz Demo for APIJSON + Nutz + NutzBoot

apijson-spring-boot Springboot3 for APIJSON, using YAML to simplify configuration

APIJSONServer Data server based on APIJSON

BankTransferNetwork Financial trading risk analyzer, based on APIJSON + Spark + Kafka

Thank you to all the enthusiastic authors for the contributions~

Please give them a ⭐ Star(on the top right) to support their hard works!


File: README-Chinese.md

APIJSON


导航目录: 项目简介 上手使用 社区生态      完整详细的导航目录 点这里查看

APIJSON 是一种专为 API 而生的 JSON 网络传输协议 以及 基于这套协议实现的 ORM 库。
为各种增删改查提供了完全自动化的万能通用接口,零代码实时满足千变万化的各种新增和变更需求。
能大幅降低开发和沟通成本,简化开发流程,缩短开发周期。
适合中小型前后端分离的项目,尤其是 创业项目、内部项目、低代码/零代码、小程序、BaaS、Serverless 等。

通过万能通用接口,前端可以定制任何数据、任何结构。
大部分 HTTP 请求后端再也不用写接口了,更不用写文档了。
前端再也不用和后端沟通接口或文档问题了。再也不会被文档各种错误坑了。
后端再也不用为了兼容旧接口写新版接口和文档了。再也不会被前端随时随地没完没了地烦了。

特点功能

对于后端

  • 提供万能通用接口,大部分 HTTP API 不用再写
  • 零代码增删改查、各种跨库连表、JOIN 嵌套子查询等
  • 自动生成文档,不用再编写和维护,且自动静态检查
  • 自动校验权限、自动管理版本、自动防 SQL 注入
  • 开放 HTTP API 无需划分版本,始终保持兼容

对于前端

  • 不用再向后端催接口、求文档
  • 数据和结构完全定制,要啥有啥
  • 看请求知结果,所求即所得
  • 可一次获取任何数据、任何结构
  • 能去除多余数据,节省流量提高速度

APIJSON 接口展示

Postman 展示 APIJSON

APIAuto 展示 APIJSON

使用 APIAuto-机器学习接口工具 来管理和测试 HTTP API 可大幅 减少传参错误、提升联调效率
(注意网页工具界面是 APIAuto,里面的 URL+JSON 才是 APIJSON 的 HTTP API):

APIJSON App 演示

使用 APIJSON + ZBLibrary 开发的 Android 客户端 Demo (以下 Gif 图看起来比较卡,实际上运行很流畅):

APIJSON 分享演讲

APIJSON-零代码接口与文档 ORM 库(国际开源谷 Gitee Meetup)

https://www.bilibili.com/video/BV1Tv411t74v

APIJSON 和 APIAuto-零代码开发和测试(QECon 全球软件质量&效能大会)

https://www.bilibili.com/video/BV1yv411p7Y4

为什么选择 APIJSON?

前后端 关于接口的 开发、文档、联调 等 10 大痛点解析 Wiki

  • 解决十大痛点 (可帮前后端开发大幅提振开发效率、强力杜绝联调扯皮、巧妙规避文档缺陷、非常节省流量带宽)
  • 开发提速很大 (CRUD 零代码热更新全自动,APIJSONBoot 对比 SSM、SSH 等保守估计可提速 20 倍以上)
  • 社区影响力大 (GitHub 18K+ Star 在 400W Java 项目排名前 100,远超 FLAG, BAT 等国内外绝大部分开源项目)
  • 各项荣誉成就 (腾讯内外 5 个奖项、QECon 大会和 Gitee Meetup 演讲、GitHub Trending 日周月榜大满贯 等)
  • 多样用户案例 (腾讯内有互娱、音乐、微信、云与智慧等,外部有华为、华能、百度、快手、中兴、圆通、传音等)
  • 适用场景广泛 (社交聊天、阅读资讯、影音娱乐、办公学习 等各种 App、网站、小程序、公众号 等非金融类项目)
  • 周边生态丰富 (Android, iOS, Web 等各种 Demo、继承 JSON 的海量生态、零代码 接口测试 和 单元测试 工具等)
  • 文档视频齐全 (项目介绍、快速上手、安装部署 等后端、前端、客户端的 图文解说、视频教程、代码注释 等)
  • 功能丰富强大 (增删改查、分页排序、分组聚合、各种条件、各种 JOIN、各种子查询、跨库连表 等零代码实现)
  • 使用安全简单 (自动增删改查、自动生成文档、自动管理版本、自动控制权限、自动校验参数、自动防 SQL 注入)
  • 灵活定制业务 (在后端编写 远程函数,可以拿到 session、version、当前 JSON 对象 等,然后自定义处理)
  • 高质可靠代码 (代码严谨规范,蚂蚁集团源伞 Pinpoint 代码扫描分析报告平均每行代码 Bug 率低至 0.15%)
  • 兼容各种项目 (协议不限 HTTP,与其它库无冲突,对各类 Web 框架集成友好且提供 SpringBoot, JFinal 的示例)
  • 工程轻量小巧 (无第三方依赖,Jar 仅 263KB,Java 文件仅 68 个共 14864 行代码,例如 APIJSONORM 8.1.0)
  • 十年持续迭代 (自 2016 年起已连续维护 9 年多,80+ 贡献者、100+ 发版、3000+ 提交,不断更新迭代中...)

按照一般互联网中小型项目情况可得出以下对比表格:

表数量 T 平均每表字段数 C SSMH 按快估计 APIJSONBoot 按慢估计 APIJSONBoot 提速倍数
1 3 179 min(约一上午) 11 min(约十分钟) 15.27
5 4 1935 min(约朝九晚六一周) 70 min(约一小时) 26.64
10 10 8550 min(大小周超半个月) 320 min(约一下午) 25.72
20 15 31900 min(约 996 两个月) 940 min(约上班两天) 32.94
50 20 176750 min(11117 超半年) 3100 min(约上班一周) 56.02

用户反馈

腾讯 IEG 数据产品开发组负责人 xinlin:
“APIJSON 开源方案,它可以做到零代码生成接口和文档,并且整个生成过程是自动化。当企业有元数据的时候,马上就可以获得接口”

腾讯科技 后台开发高级工程师 雷大锤:
“可以抽出时间来看apijson了,这个可以为T10做准备,也是业界很火的东西,可以提升个人影响力!”

腾讯 bodian520:
“在调试GET、POST、PUT接口时遇到了一些问题,把个人的摸索经验分享一下,希望作者能梳理下文档,方便我们更好的接入”

华为 minshiwu:
“demo工程,默认使用apijson-framework,可以做到无任何配置即可体验apijson的各种能力。”

字节跳动 qiujunlin:
“初次见到这个项目,觉得太惊艳了,眼前一亮。给我的感受是,项目大大简化了开发流程,开发效率提升了很多倍。”

百度智慧城市研发 lpeng:
“很兴奋的发现APIJSON很适合我们的一个开发场景,作为我们协议定义的一部分”

中兴 duyijiang:
“感谢腾讯大大提供的框架,很好用”

https://github.com/APIJSON/APIJSON/issues/132#issuecomment-1106669540

常见问题

1.如何定制业务逻辑?

在后端编写 远程函数,可以拿到 session、version、当前 JSON 对象、参数名称 等,然后对查到的数据自定义处理 issues#101

2.如何控制权限?

在 Access 表配置校验规则,默认不允许访问,需要对 每张表、每种角色、每种操作 做相应的配置,粒度细分到行级 issues#12

3.如何校验参数?

在 Request 表配置校验规则 structure,提供 MUST、TYPE、VERIFY 等通用方法,可通过 远程函数 来完全自定义 Wiki

更多常见问题及提问前必看 issues#36

注意事项

请求参数 JSON 中表名、字段名、关键词及对应的值都是大小写敏感、逗号敏感、分号敏感、空格敏感、换行敏感,
大部分情况都不允许空格和换行,表名以大写字母开头,不要想当然,请严格按照 设计规范 来调用 API !

issues#181

导航目录: 项目简介 上手使用 社区生态      完整详细的导航目录 点这里查看

快速上手

1.后端上手 [](https://jitpack.io/#APIJSON/APIJSON)

可以跳过这个步骤,直接用APIJSON服务器IP地址 apijson.cn:8080 来测试接口。
见  APIJSON后端上手 - Java

2.前端上手

可以跳过这个步骤,直接使用 APIAuto-机器学习HTTP接口工具 或 下载客户端App。
见  Android  或  iOS  或  JavaScript

下载客户端 App

仿微信朋友圈动态实战项目
APIJSONApp.apk

测试及自动生成代码工具
APIJSONTest.apk

开源许可

使用 Apache License 2.0,对 公司、团队、个人 等 商用、非商用 都自由免费且非常友好,请放心使用和登记

使用登记

如果您在使用 APIJSON,请让我们知道,您的使用对我们非常重要(新的按登记顺序排列、专群优先答疑解惑):
https://github.com/APIJSON/APIJSON/issues/187

贡献者们

主项目 APIJSON 的贡献者们(7 个腾讯工程师、1 个微软工程师、1 个阿里云工程师、1 个字节跳动工程师、1 个网易工程师、1 个 Zoom 工程师、1 个圆通工程师、1 个知乎基础研发架构师、1 个智联招聘工程师、gorm-plus 作者、1 个美国加州大学学生、3 个 SUSTech 学生等):

生态周边项目的作者们(2 个腾讯工程师、1 个 BAT 技术专家、1 个微软工程师、2 个字节跳动工程师、1 个神州数码工程师&Apache dubbo2js 作者 等):
https://github.com/search?o=desc&q=apijson&s=stars&type=Repositories
https://search.gitee.com/?skin=rec&type=repository&q=apijson&sort=stars_count

还有 腾讯安全、蚂蚁集团源伞、奇安信代码卫士 提交安全报告(Issue)等



感谢大家的贡献。

统计分析

腾讯、华为、阿里巴巴、美团、字节跳动、百度、京东、网易、快手等和 Google, Apple, Microsoft, Amazon, Paypal, IBM, Shopee 等
数百名知名大厂员工点了 Star,也有腾讯、华为、字节跳动、Microsoft、Zoom 等不少知名大厂员工提了 PR/Issue,感谢大家的支持~

根据开源指南针报告,APIJSON Java 版已经是国内顶级、国际一流的 Java 开源项目了 #518

规划及路线图

新增功能、强化安全、提高性能、增强稳定、完善文档、丰富周边、推广使用

理论上所有支持 SQL 与 JDBC/ODBC 的软件,都可以用本项目对接 CRUD,待测试:
OceanBase, Spark(可用 Hive 对接), Phoenix(延伸支持 HBase)

我要赞赏

创作不易,坚持更难,右上角点亮 ⭐ Star 来收藏/支持下吧,谢谢 ^_^
https://github.com/APIJSON/APIJSON

导航目录: 项目简介 上手使用 社区生态      完整详细的导航目录 点这里查看

技术交流

如果有什么问题或建议可以 填问卷 或 提 Issue,交流技术,分享经验。
如果你解决了某些 bug,或者新增了一些功能,欢迎 贡献代码,感激不尽~

开发者也是人,也需要工作、休息、恋爱、陪伴家人、走亲会友等,也有心情不好和身体病痛,
往往没有额外的时间精力顾及一些小问题,请理解和支持,开源要大家参与贡献才会更美好~
少数个人的热情终有被耗尽的一天,只有大家共同建设和繁荣社区,才能让开源可持续发展!

开发者时间精力有限,原则上优先解决 登记用户 和 贡献者 的问题,
不解决 文档/视频/常见问题 已明确说明、描述简陋 或 态度无礼 的问题!
如果你已经多次得到帮助,却仍然只索取不贡献,那就别指望大家再帮你!
私聊作者请教技术问题 或者 频繁在互助群 @ 作者 可能会被拉黑/禁言/踢群,请尊重和理解,谢谢!

如果你 提 PR 登记了自己使用 APIJSON 的公司,可以加 企业用户支持专群,作者亲自且优先答疑,
作者只有解答完了这个专群里的全部问题,才看情况解答 Issue/问卷 里的问题(对 Issue/问卷 不保证解答、更不保证及时);
之前的几个互助群,由于大多数问题 在文档/Issue 已有答案却反复提 或者 缺少必要信息要来来回回沟通问清细节 已浪费太多时间,
甚至有白嫖还把自己当大爷的自私自利伸手党输出情绪,我们不再支持,建议未登记企业的用户 填问卷 或 提 Issue。

如果你为 APIJSON 做出了以下任何一个贡献,我们将优先为你答疑解惑:
提交了 PR 且被合并、提交了优质 Issue、发表了优质文章、开发了可用的生态项目,
Issue/问卷 一般解答顺序:贡献者 > 帮助他人的用户 > 提供任职企业的用户 > 其他用户。

相关推荐

APIJSON, 接口和文档的终结者!

腾讯业务百万数据 6s 响应,APIJSON 性能优化背后的故事

仿QQ空间和微信朋友圈,高解耦高复用高灵活

后端开挂:3行代码写出8个接口!

后端自动化版本管理,再也不用改URL了!

3步创建APIJSON后端新表及配置

APIJSON对接分布式HTAP数据库TiDB

APIJSON教程(一):上手apijson项目,学习apijson语法,并实现持久层配置

apijson简单demo

apijson简单使用

APIJSON简单部署和使用

学习自动化接口APIJSON

APIJSON 接口调试实践

APIJSON-零代码接口和文档 JSON 协议 与 ORM 库

APIJSON使用例子总结

APIJSON 自动化接口和文档的快速开发神器 (一)

APIJSON在mac电脑环境下配置去连接SQL Server

APIJSON复杂业务深入实践(类似12306订票系统)

新手搭建 APIJSON 项目指北

使用APIJSON写低代码Crud接口

apijson在同一个接口调用中 使用远程函数写入更新时间和创建时间

APIJSON(一:综述)

APIJSON 代码分析(三:demo主体代码)

APIJSON 代码分析(二)AbstractParser类(解析器)

APIJSON 代码分析(四:AbstractObjectParser源码阅读)

APIJSON 代码分析 AbstractSQLConfig 第二篇

APIJSON 代码分析(六)APIJSON—Verifier检查类

APIJSON 代码分析(四)AbstractSQLExecutor—SQL执行器

APIJSON使用

apijson 初探

APIJSON使用介绍

MassCMS With APIJSON最佳实践

APIJSON语法使用,超详细

wend看源码-ORM-APIJSON

APIJSON – The No-Code API Revolution That Puts Developers in the Fast Lane

APIJSON:17.4k Star!零代码接口与文档协议及ORM库

APIJSON-后端开发神器!!!

apijson 快速上手

APIJSON快速入门-零后端代码,接口所见即所得

零代码,全自动万能API接口

APIJSON项目实战教程:零代码实现高效JSON接口开发

springboot整合APIJSON——零代码万能通用 API(附源码)

APIJSON:重新定义后端开发体验的零代码ORM框架

API自动生成这么爽?实测 APIJSON,零代码就能玩转后端接口!

APIJSON:后端接口不用写了?

3分钟掌握APIJSON搜索黑科技:从模糊匹配到智能检索

省心省力的后端神器——APIJSON.NET

生态项目

APIJSON-Demo APIJSON 各种语言、各种框架 的 使用示例项目、上手文档、测试数据 SQL 文件 等

A2API AI 生成一次 UI,API 每次都安全、快速、稳定操作数据。聊天生成 UI 来安全、快速、稳定增删改查表格、表单、图表等数据。

apijson-orm APIJSON ORM 库,可通过 Maven, Gradle 等远程依赖

apijson-framework APIJSON 服务端框架,通过数据库表配置角色权限、参数校验等,简化使用

apijson-router APIJSON 的路由插件,可控地对公网暴露类 RESTful 简单接口,内部转成 APIJSON 格式请求来执行

apijson-column APIJSON 的字段插件,支持 字段名映射 和 !key 反选字段

apijson-jackson APIJSON 的 jackson 插件,简化使用

apijson-fastjson2 APIJSON 的 fastjson2 插件,简化使用

apijson-gson APIJSON 的 gson 插件,简化使用

apijson-milvus APIJSON 的 Milvus AI 向量数据库插件

apijson-influxdb APIJSON 的 InfluxDB 物联网时序数据库插件

apijson-mongodb APIJSON 的 MongoDB NoSQL 数据库插件

apijson-cassandra APIJSON 的 Cassandra NoSQL 数据库插件

APIAuto ☔ 敏捷开发最强大易用的接口工具,零代码测试与 AI 问答、生成代码与静态检查、生成文档与光标悬浮注释,腾讯、SHEIN、传音 等使用

CVAuto 👁 零代码零标注 CV AI 自动化测试平台 🚀 免除大量人工画框和打标签等,直接快速测试 CV 计算机视觉 AI 图像识别算法

UnitAuto 最先进、最省事、ROI 最高的单元测试,机器学习 零代码、全方位、自动化 测试 方法/函数,用户包含腾讯、快手、某 500 强巨头等

SQLAuto 智能零代码自动化测试 SQL 数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据

UIGO 📱 零代码快准稳 UI 智能录制回放平台 🚀 3 像素内自动精准定位,2 毫秒内自动精准等待,用户包含腾讯,微信团队邀请分享

apijson-doc APIJSON 官方文档,提供排版清晰、搜索方便的文档内容展示,包括设计规范、图文教程等

APIJSONdocs APIJSON 英文文档,提供排版清晰的文档内容展示,包括详细介绍、设计规范、使用方式等

apijson.org APIJSON 官方网站,提供 APIJSON 的 功能简介、登记用户、作者与贡献者、相关链接 等

APIJSON.NET C# 版 APIJSON ,支持 MySQL, PostgreSQL, SQL Server, Oracle, SQLite

apijson-go Go 版 APIJSON , 基于Go(>=1.18) + GoFrame2, 支持查询、单表增删改、权限管理等

apijson-go Go 版 APIJSON ,支持单表查询、数组查询、多表一对一关联查询、多表一对多关联查询 等

apijson-hyperf PHP 版 APIJSON,基于 Hyperf 支持 MySQL

APIJSON-php PHP 版 APIJSON,基于 ThinkPHP,支持 MySQL, PostgreSQL, SQL Server, Oracle 等

apijson-php PHP 版 APIJSON,基于 ThinkPHP,支持 MySQL, PostgreSQL, SQL Server, Oracle 等

apijson-node 字节跳动工程师开源的 Node.ts 版 APIJSON,提供 nestjs 和 typeorm 的 Demo 及后台管理

nestjs-apijson APIJSON NestJS 版,支持 CRUD、JOIN、各种条件,适配 MySQL, PostgreSQL, SQLite (AI 辅助)

uliweb-apijson Python 版 APIJSON,支持 MySQL, PostgreSQL, SQL Server, Oracle, SQLite 等

apijson-rust APIJSON 的 Rust 版,一个优雅、高性能的 Rust 多数据源管理系统,支持 MySQL 和 PostgreSQL (AI 辅助)

APIJSONParser 第三方 APIJSON 解析器,将 JSON 动态解析成 SQL

FfApiJson 用 JSON 格式直接生成 SQL,借鉴 APIJSON 支持多数据源

APIJSON-ToDo-Demo 一个简单的 todo 示例项目,精简数据,简化上手流程,带自定义鉴权逻辑

apijson-learn APIJSON 学习笔记和源码解析

apijson-practice BAT 技术专家开源的 APIJSON 参数校验注解 Library 及相关 Demo

apijson-db2 微软工程师接入 IBM 数据库 DB2 的 APIJSON 使用 Demo

APIJSONDemo 字节跳动工程师接入 ClickHouse 的 APIJSON 使用 Demo

APIJSONDemo_ClickHouse APIJSON + SpringBoot 连接 ClickHouse 使用的 Demo

APIJSONBoot_Hive APIJSON + SpringBoot 连接 Hive 使用的 Demo

apijson-sample APIJSON 简单使用 Demo 及教程

apijson-examples APIJSON 的前端、业务后端、管理后端 Demo

apijson-ruoyi APIJSON 和 RuoYi 框架整合,实现零代码生成页面模板接口,在线维护 APIJSON 数据库配置等

light4j 整合 APIJSON 和微服务框架 light-4j 的 Demo,同时接入了 Redis

SpringServer1.2-APIJSON 智慧党建服务器端,提供 上传 和 下载 文件的接口

apijson_template APIJSON Java 模版,使用 gradle 管理依赖和构建应用

api-json-demo 基于 APIJSON,实现低代码写 CURD 代码,代替传统 ORM 框架,适配 Oracle 事务

ApiJsonByJFinal 整合 APIJSON 和 JFinal 的 Demo

bookmark goframe + apijson-go + vue3 + antd vue 4 的在线书签

apijson-go-demo apijson-go demos,提供 3 个从简单到复杂的不同场景 Demo

apijson-builder 一个方便为 APIJSON 构建 RESTful 请求的 JavaScript 库

apijson-go-ui apijson-go UI 界面配置, 支持权限管理、请求规则配置等

AbsGrade 列表级联算法,支持微信朋友圈单层评论、QQ空间双层评论、百度网盘多层(无限层)文件夹等

APIJSON-Android-RxJava 仿微信朋友圈动态实战项目,ZBLibrary(UI) + APIJSON(HTTP) + RxJava(Data)

Android-ZBLibrary Android MVP 快速开发框架,Demo 全面,注释详细,使用简单,代码严谨

apijson-dynamic-datasource 基于APIJSON,动态切换数据源、同一数据源批量操作事务一致性DEMO

xyerp 基于ApiJson的低代码ERP

quick-boot 基于 Spring Cloud 2022、Spring Boot 3、AMIS 和 APIJSON 的低代码系统。

apijson-query-spring-boot-starter 一个快速构建 APIJSON 查询条件的插件

apijson-builder 简单包装 APIJSON,相比直接构造查询 JSON 更好记,ts 编写,调整了一些参数和使用方式

lanmuc 后端低代码生产接口的平台,兼容配置式接口和编写式接口,可做到快速生产接口,上线项目

review_plan 复习提醒Web版(Java技术练习项目)

apijson-nutz APIJSON + Nutz 框架 + NutzBoot 的 Demo

apijson-spring-boot Springboot3 for APIJSON,用 YAML 简化代码配置

APIJSONServer 基于APIJSON实现的数据服务端

BankTransferNetwork 基于 APIJSON + Spark + Kafka 构建的金融交易网络风险图谱分析系统

感谢热心的作者们的贡献,点亮 ⭐ Star 收藏/支持下他们吧~

犀牛鸟开源人才培养计划

https://github.com/APIJSON/APIJSON/issues/229

qiujunlin **2.接入 presto/hive/clickhouse/db2 任意一个**

APIJSON 接入 clickhouse 使用demo
https://github.com/qiujunlin/APIJSONDemo

zhangshukun 2.接入 presto/hive/clickhouse/db2 任意一个

APIJSON-Demo接入db2
https://github.com/andream7/apijson-db2

hanxu 1.完善入门介绍视频

重构 APIJSON 文档
https://hanxu2018.github.io/APIJSON-DOC/
文档源码
https://github.com/HANXU2018/APIJSON-DOC
配套评论区 apijson-doc-Comment
https://github.com/HANXU2018/apijson-doc-Comment

chenyanlan 2.接入 presto/hive/clickhouse/db2 任意一个

APIJSON + SpringBoot连接ClickHouse使用的Demo
https://github.com/chenyanlann/APIJSONDemo_ClickHouse

zhaoqiming 1.完善入门介绍视频

APIJSON 后端教程(1):简介
https://www.bilibili.com/video/BV1vL411W7yd

APIJSON 后端教程(2):数据库
https://www.bilibili.com/video/BV1eB4y1N77s

APIJSON 后端教程(3):Demo
https://www.bilibili.com/video/BV1FX4y1c7ug

APIJSON 后端教程(4):Boot
https://www.bilibili.com/video/BV18h411z7FK

APIJSON 后端教程(5):Final
https://www.bilibili.com/video/BV1GM4y1N7XJ

APIJSON 后端教程(6):uliweb_apijson
https://www.bilibili.com/video/BV1yb4y1S79v/

APIJSON 后端教程(7):问题答疑
https://www.bilibili.com/video/BV1dQ4y1h7Df

APIJSON配套文档:
https://github.com/kenlig/apijsondocs

huwen 2.接入 presto/hive/clickhouse/db2 任意一个

APIJSON-Demo 接入presto
https://github.com/hclown9804/APIJSONDemo_presto

zhanghaoling 1.完善入门介绍视频

APIJSON结合已有项目,简化开发流程
https://github.com/haolingzhang1/APIJson--demo

说明文档
https://github.com/haolingzhang1/APIJson--demo/tree/main/APIJson集成项目说明

(1)官方demo
https://github.com/haolingzhang1/APIJson--demo/blob/main/APIJson集成项目说明/APIJson集成现有项目(1)-%20官方demo.pdf

(2)单表配置
https://github.com/haolingzhang1/APIJson--demo/blob/main/APIJson集成项目说明/APIJson集成现有项目(2)-%20单表配置.pdf

zhoukaile 1.完善入门介绍视频

视频链接:https://www.bilibili.com/video/BV1Uh411z7kZ/

文档链接:https://gitee.com/funkiz/apijson_camp

lintao 1.完善入门介绍视频

APIJSON 上手教程:https://www.bilibili.com/video/BV1Pq4y1n7rJ

持续更新

https://github.com/Tencent/APIJSON/commits/master


File: README-extend.md

功能点

一个json(事务)同时支持新增、修改、删除、查询、别名

https://github.com/Tencent/APIJSON/issues/468

使用说明

json 支持多种方式定义 method

第一种:

"@post","@put","@delete","@head","@get","@gets","@head","@heads"

"@post": "Moment,Comment[]" , 值为 String 或 JSONObject 格式, 为 String 时每个 value = key,为 JSONObject 时:

json
"@post": { 
   "Moment": "Moment", // 只指定 tag,为 "" 则和 key 一致
   "Comment[]": { // 同时指定多个全局关键词
      "tag": "Comment[]",
      "version": 2
      // 其它全局关键词
   }
}

需要保证每个key唯一, 唯一判断标准:

key = Moment

key= Moment[]

会判断为相同key. 请通过别名区分, 别名格式: Sys_user_role:sur xxx表名:别名

text
{
   "@post": "Moment,Comment:cArray[],User:u", // 分发到 POST 请求对应的解析处理
   "Moment": {
     // TODO 其它字段
   },
   "Comment:cArray[]": [
      {
        // TODO 其它字段
      }
   ],
   "@get": "User", // 分发到 GET 请求对应的解析处理
   "User:u": {
     // TODO 其它字段
   },
   "Privacy": { // 按 URL 对应的默认方法处理
     // TODO 其它字段
   }
}

同一事务中对同一张表执行删除和批量新增时,需要通过别名保证 key 唯一。`@post`、`@delete` 等方法指令的 value 只能是 String 或 JSONObject,不能使用 JSONArray:

```json
{
   "@delete": {
      "MobilizeTaskInfo:remove": "MobilizeTaskInfo"
   },
   "MobilizeTaskInfo:remove": {
      "id{}": ["09a7a740-1935-469a-ab76-ea1ee1f94ddc"]
   },
   "@post": {
      "MobilizeTaskInfo:add[]": "MobilizeTaskInfo:[]"
   },
   "MobilizeTaskInfo:add[]": [
      {
         "leading_unit_name": "市交通局",
         "serial_number": "GD2025-064",
         "status": 1
      }
   ]
}

对于没有显式声明操作方法的,直接用 URL(/get, /post 等) 对应的默认操作方法

text
#### 第二种: @Deprecated 即将弃用,请使用第一种

对象内定义"@method": "GET", value大写

{
"sql@": {
"@method": "GET",
"with": true,
"from": "Sys_role",
"Sys_role": {
"@column": "id",
"role_name": "角色1"
}
},
"Sys_user_role:sur[]": {
"@method": "GET",
"Sys_user_role": {
"role_id{}@": "sql"
}
},
"Sys_role_permission:srp[]": {
"@method": "GET",
"Sys_role_permission": {
"role_id{}@": "sql"
}
},
"@explain": true
}

text
#### 解析顺序

1) 对象内 "@method"
2) "@post","@put","@delete"
3) 对于没有显式声明操作方法的,直接用 URL(/get, /post 等) 对应的默认操作方法

#### tag自动生成规则

/**
 * { "xxx:aa":{ "@tag": "" }}
 * 生成规则:
 * 1、@tag存在,tag=@tag
 * 2、@tag不存在
 * 1)、存在别名
 * key=对象: tag=key去除别名
 * key=数组: tag=key去除别名 + []
 * 2)、不存在别名
 * tag=key
 * tag=key + []
 */





#### 建议

1. 一个json包含不同操作方法, url method 使用 /post, /put
2. value为JSONArray, 建议通过"@post" 方式配置, 如果没有配置,执行 3

#### Request表 配置说明

这只是我的配置仅供参考, 后续 测试会用到:

单条新增:
POST User_address {"MUST":"addr","UPDATE": {"@role": "OWNER,ADMIN","childFunTest-()": "childFunTest(addr)"}, "REFUSE": "id"}
批量新增:
POST User_address[] {"User_address[]": [{"MUST":"addr","REFUSE": "id"}], "UPDATE": {"@role": "OWNER,ADMIN","childFunTest-()": "childFunTest(addr)"}}
单条修改:
PUT User_address {"User_address":{ "MUST":"id","REFUSE": "userId", "UPDATE": {"@role": "OWNER,ADMIN","childFunTest-()": "childFunTest(addr)"}} }
批量修改:
PUT User_address[] {"User_address[]": [{"MUST": "id","REFUSE": "userId"}], "UPDATE": {"@role": "OWNER,ADMIN"}}
删除:
DELETE User_address {"User_address":{ "MUST":"id{}","REFUSE": "!", "INSERT": {"@role": "OWNER,ADMIN"}} }

text
### 别名

格式: 

Sys_user_role:sur  xxx表名:别名

Comment:cArray[]

#### 实现思路

当时参考了作者的示例: 注册流程. 看到绕过校验, 可以将多条json语句组装在一起, 批量执行. 于是就想如何实现一个json支持不同操作方法,并支持事物. 

通过分析源码, 熟悉了校验流程、json解析执行流程、json解析生成sql语句流程、一些兼容、校验规则等

经过和作者讨论, 很感谢作者提供了相关解决方案和思路. 逐步理解了apijson的设计原理和框架结构.

一个json(事务)同时支持新增、修改、删除、查询、别名, 实现思路如下:

1、校验模块

将json解析成对象、临时变量、子查询、别名、tag等

并将method 添加到 json对象属性中.

```json
"Sys_role": {
    "@method": "PUT",
    "id": "6aedce0d-2a29-4fbe-aeed-0ba935ca6b41",
    "id{}@": "sql",
    "role_code": "code-subrange-4",
    "role_name": "角色-subrange-4"
}

2、对象解析

用对象属性@method , 替换 Parser 的 method

3、事物支持

后续优化建议

1、独立定义一个url method, 通过解析不同method执行不同流程

和已有method区分开,避免歧义

2、最外层新增传参 "transaction": true 来指定开启事务
目前是url put、post来控制开启事物, 以及提交的时候 在 AbstractParser onCommit 判断 transactionIsolation (4 : 开启事物, 0: 非事物请求)

详细实现请参见: https://github.com/Tencent/APIJSON/issues/468

3、完善 "@Explain"

如果没有执行计划,则返回sql语句. 能够在 reponse返回值中, 看到json中执行的每条sql,方便排错

4、@version支持

定义不同场景的 新增、修改、删除等执行规则. 请通过version版本区分

Request表是通过tag、method、version来保证唯一.

5、前置函数

前置函数能够将json语句, 加入到 当前事物中.

例如: 像数组一样,解析成每一条语句去执行.

mysql8 with-as表达式

前提条件

1、mysql版本: 8+

2、mysql-connector-java: 8.0.31

版本支持 with-as即可

3、druid: 1.2.15

版本支持 with-as即可

4、去掉 durid wall配置

delete子查询, druid wall 拦截器报错 sql injection violation

测试案例

查询单个range ref引用

text
// 测试 mysql8 with as表达式
// 用户表
// 用户角色表
// 角色表
// 示例一 单个range ref引用
{
	"sql@": {
    	"@method": "GET",
        "with": true,
        "from": "Sys_role",
        "Sys_role": {
          "@column": "id",
          "role_name": "角色1"
        }
    },
    "Sys_user_role:sur[]": {
    	"@method": "GET",
        "Sys_user_role": {
            "role_id{}@": "sql"
        }
    },
    "Sys_role_permission:srp[]": {
    	"@method": "GET",
        "Sys_role_permission": {
            "role_id{}@": "sql"
        }
    },
    "@explain": true
}  

// 第二种写法
{
	"@get": ["sql@","Sys_user_role:sur[]","Sys_role_permission:srp[]"],
	"sql@": {
        "with": true,
        "from": "Sys_role",
        "Sys_role": {
          "@column": "id",
          "role_name": "角色1"
        }
    },
    "Sys_user_role:sur[]": {
        "Sys_user_role": {
            "role_id{}@": "sql"
        }
    },
    "Sys_role_permission:srp[]": {
        "Sys_role_permission": {
            "role_id{}@": "sql"
        }
    },
    "@explain": true
}

mysql8执行结果:

mysql5.7执行结果:

查询多个range ref引用

text
{
    "sql@": {
        "@method": "GET", 
        "with": true, 
        "from": "Sys_role", 
        "Sys_role": {
            "@column": "id", 
            "role_name": "角色1"
        }
    }, 
    "sql_user@": {
        "@method": "GET", 
        "with": true, 
        "from": "Sys_user", 
        "Sys_user": {
            "@column": "id", 
            "id": "f0894db2-6940-4d89-a5b2-4405d0ad0c8f"
        }
    }, 
    "Sys_user_role:sur[]": {
        "@method": "GET", 
        "Sys_user_role": {
            "role_id{}@": "sql", 
            "user_id{}@": "sql_user"
        }
    }, 
    "Sys_role_permission:srp[]": {
        "@method": "GET", 
        "Sys_role_permission": {
            "role_id{}@": "sql"
        }
    }, 
    "@explain": true
}

mysql8执行结果:

mysql5.7执行结果:

delete子查询

j s
{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_role_permission",
        "Sys_role_permission": {
          "@column": "id",
		  "role_id{}": ["e7129d5f-b07e-4996-9965-9528e370a393"]
        }
    },
    "Sys_role_permission": {
    	"@method": "DELETE",
        "id{}@": "sql"
    },
    "explan": true
}

mysql8执行sql语句:

text
WITH  `sql` AS (SELECT `id` FROM `housekeeping`.`Sys_role_permission` WHERE  (  (`role_id` IN ('68877ee9-4cf4-4f32-86e6-16c505ca3b21'))  ) ) DELETE FROM `housekeeping`.`Sys_role_permission` WHERE  (  (`id` IN ( SELECT * FROM `sql`) )  ) 

Plain Text

mysql5.7执行结果:

text
DELETE FROM `housekeeping`.`Sys_role_permission` WHERE  (  (`id` IN ( SELECT * FROM (SELECT `id` FROM `housekeeping`.`Sys_role_permission` WHERE  (  (`role_id` IN ('20d337bb-9886-455f-8dce-f1cadab0ec4f'))  ) ) AS `sql`) )  ) 



Plain Text

update子查询

text
{
   "sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_role_permission",
        "Sys_role_permission": {
          "@column": "role_id",
		  "id{}": ["6aedce0d-2a29-4fbe-aeed-0ba935ca6b41"]
        }
    },
    "Sys_role": {
    	"@method": "PUT",
		"id": "6aedce0d-2a29-4fbe-aeed-0ba935ca6b41",
        "id{}@": "sql",
        "role_code": "code-subrange-4",
        "role_name": "角色-subrange-4"
    },
    "@explain": true
}

第二种写法
{
	"@get": ["sql@"],
    "sql@": {
        "with": true,
        "from": "Sys_role_permission",
        "Sys_role_permission": {
          "@column": "role_id",
		  "id{}": ["c95ef2d6-bf14-42b0-bb87-038cee8c78f1"]
        }
    },
    "@put": ["Sys_role"],
    "Sys_role": {
		"id": "0bb92d96-8ca6-469e-91e8-60308ce5b835",
        "id{}@": "sql",
        "role_code": "code-subrange-4",
        "role_name": "角色-subrange-4"
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

GETS 单条子查询

会执行校验流程

text
http://localhost:8675/lowCodePlatform/forms/api/gets

{
	"sql@": {
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "role_id",
		  "user_id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_role[]": {
        "Sys_role": {
            "id{}@": "sql"
        },
        "page": 0,
        "count": 10,
        "query": 2
    },
    "tag":"Sys_role[]",
    "total@": "/Sys_role[]/total",
    "@explain": true
}

第二种写法
{
	"@gets": ["sql@","Sys_role[]"],
	"sql@": {
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "role_id",
		  "user_id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_role[]": {
        "Sys_role": {
            "id{}@": "sql"
        },
        "page": 0,
        "count": 10,
        "query": 2
    },
    "tag":"Sys_role[]",
    "total@": "/Sys_role[]/total",
    "@explain": true
}

Access、Request需要配置鉴权信息:

mysql8执行sql语句:

mysql5.7执行结果:

GETS多条子查询

会执行校验流程

text
http://localhost:8675/lowCodePlatform/forms/api/gets

{
	"sql@": {
    	"@method": "GETS",
        "with": true,
        "from": "Sys_role",
        "Sys_role": {
          "@column": "id",
          "role_name": "超级管理员"
        }
    },
    "sql_user@": {
    	"@method": "GETS",
        "with": true,
        "from": "Sys_user",
        "Sys_user": {
          "@column": "id",
          "id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_user_role:sur[]": {
    	"@method": "GETS",
        "Sys_user_role": {
            "role_id{}@": "sql",
            "user_id{}@": "sql_user"
        }
    },
    "Sys_role_permission:srp[]": {
    	"@method": "GETS",
        "Sys_role_permission": {
            "role_id{}@": "sql"
        }
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

普通获取数量, get/head不执行校验流程

text
http://localhost:8675/lowCodePlatform/forms/api/head
{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "role_id",
		  "user_id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_role": {
    	"@method": "head",
        "id{}@": "sql"
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

普通获取数量, get/head不执行校验流程

text
{
	"sql@": {
    	"@method": "GET",
        "with": true,
        "from": "Sys_role",
        "Sys_role": {
          "@column": "id",
          "role_name": "超级管理员"
        }
    },
    "sql_user@": {
    	"@method": "GET",
        "with": true,
        "from": "Sys_user",
        "Sys_user": {
          "@column": "id",
          "id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_user_role": {
        "@method": "HEAD",
        "role_id{}@": "sql",
            "user_id{}@": "sql_user"
    },
    "Sys_role_permission": {
        "@method": "HEAD",
        "role_id{}@": "sql"
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

heads 单个子查询

普通获取数量

会执行校验流程, Access、Request需要配置鉴权信息:

text
http://localhost:8675/lowCodePlatform/forms/api/heads

{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "role_id",
		  "user_id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_role": {
    	"@method": "heads",
        "id{}@": "sql"
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

heads 多个子查询

会执行校验流程, Access、Request需要配置鉴权信息:

普通获取数量

text
{
	"sql@": {
    	"@method": "GET",
        "with": true,
        "from": "Sys_role",
        "Sys_role": {
          "@column": "id",
          "role_name": "超级管理员"
        }
    },
    "sql_user@": {
    	"@method": "GET",
        "with": true,
        "from": "Sys_user",
        "Sys_user": {
          "@column": "id",
          "id": "4732209c-5785-4827-b532-5092f154fd94"
        }
    },
    "Sys_user_role": {
        "@method": "HEADS",
        "role_id{}@": "sql",
        "user_id{}@": "sql_user"
    },
    "Sys_role_permission": {
        "@method": "HEADS",
        "role_id{}@": "sql"
    },
    "@explain": true
}

mysql8执行sql语句:

mysql5.7执行结果:

delete、put 支持子查询

https://github.com/Tencent/APIJSON/issues/471

静态变量做全局处理,特殊接口用 Operation.MUST id/id{}/id{}@ 做自定义处理。

之所以默认必传,是因为安全意识不够、编码粗心大意的人太多了,所以要有一个底线保障,尽可能避免安全隐患。

1、全局配置 为 PUT, DELETE 强制要求必须有 id/id{}/id{}@ 条件

AbstractVerifier.IS_UPDATE_MUST_HAVE_ID_CONDITION = true; // true: 必须有

2、细粒度控制

使用说明

text
// 条件删除
```json
{
    "User:del": {
        "username": "test3"
    },
    "tag": "User",
    "explain": true
}

// 引用id{}@删除

json
{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "user_id",
		  "role_id{}": ["023e1880-c0d4-4e7c-ae6c-7703199c2daf"]
        }
    },
    "Sys_user:aa": {
    	"@method": "DELETE",
        "id{}@": "sql"
    },
    "explan": true
}

// 子查询条件删除
http://localhost:8675/lowCodePlatform/forms/api/delete

json
{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "User",
        "User": {
          "@column": "username",
		  "username": "test-3"
        }
    },
    "User": {
        "username{}@": "sql"
    },
    "explan": true
}

第二种写法:

json
{
	"@get": ["sql@"],
	"sql@": {
        "with": true,
        "from": "User",
        "User": {
          "@column": "username",
		  "username": "test4"
        }
    },
    "User": {
        "username{}@": "sql"
    },
    "explan": true
}

开启id删除, 删除失败:

json
{
    "@get": ["sql@"],
    "sql@": {
        "with": true,
        "from": "User",
        "User": {
            "@column": "username",
            "username": "test4"
        }
    },
    "User": {
        "username{}@": "sql"
    },
    "explan": true
}

开启id删除、id引用 删除成功

json
{
	"sql@": {
		"@method": "GET",
        "with": true,
        "from": "Sys_user_role",
        "Sys_user_role": {
          "@column": "user_id",
		  "role_id{}": ["0bb92d96-8ca6-469e-91e8-60308ce5b835"]
        }
    },
    "Sys_user:aa": {
    	"@method": "DELETE",
        "id{}@": "sql"
    },
    "explan": true
}

PUT 子查询 修改

json
{
   "sql@": {
	"@method": "GET",
        "with": true,
        "from": "Sys_role_permission",
        "Sys_role_permission": {
             "@column": "role_id",
	     "id{}": ["ba2634f8-0bdc-4b50-9c5e-47786b1536ef"]
        }
    },
    "Sys_role": {
    	"@method": "PUT",
        "id{}@": "sql",
        "role_code": "code-subrange-5",
        "role_name": "角色-subrange-5"
    },
    "@explain": true
}

bug修复

删除操作 主表 和 子查询 是同一张表
mysql8以下 非with-as表达式 会报错:
"msg": "You can't specify target table 'User' for update in FROM clause",

需要调整sql语句,将子查询包一层(select * from (子查询) as xxx)
DELETE FROM housekeeping.User
WHERE ( (username IN (SELECT * FROM (SELECT username FROM housekeeping.User WHERE ( (username = 'test1') )) as a) ) )

must、refuses判断、delete、PUT支持 ref

json
{
    "sql@": {
	"@method": "GET",
        "with": true,
        "from": "Sys_role_permission",
        "Sys_role_permission": {
            "@column": "id",
	    "role_id{}": ["94f79f0b-331b-4cc5-bfc0-ebfc47d00f13"]
        }
    },
    "Sys_role_permission": {
    	"@method": "DELETE",
        "id{}@": "sql"
    },
    "explan": true
}

2. Official Technical Reference & Guides (Tencent/Tencent.github.io)

File: konajdk/sm/README.md

Tencent Kona JDK ShangMi Reference Guide

Overview of ShangMi

ShangMi is a set of cryptographic techniques and tools in commercial or business applications, including the encryption of sensitive business data, secure communication channels, digital signatures for document verification, and even more.

Generally, the below ShangMi cryptographic algorithms and secure communication protocols are widely applied.

ShangMi cryptographic algorithms

  • SM2, which is a public key algorithm based on Elliptic Curve Cryptography (ECC). It complies with China's specifications:
    • GB/T 32918.1-2016 Part 1:General
    • GB/T 32918.2-2016 Part 2:Digital signature algorithm
    • GB/T 32918.3-2016 Part 3:Key exchange protocol
    • GB/T 32918.4-2016 Part 4:Public key encryption algorithm
    • GB/T 32918.5-2017 Part 5:Parameter definition
  • SM3, which is a cryptographic hash algorithm. It complies with China's specification:
    • GB/T 32905-2016 SM3 cryptographic hash algorithm
  • SM4, which is a block encryption algorithm. It complies with China's specification:
    • GB/T 32907-2016 SM4 block cipher algorithm

ShangMi secure communication protocols

  • Transport Layer Cryptography Protocol (TLCP), which is a TLS liked protocol. This protocol requires an endpoint must have two certificates, one for signature and the other for encryption. It complies China's specification:
    • GB/T 38636-2020 Information security technology-Transport layer cryptography protocol (TLCP)
  • ShangMi (SM) Cipher Suites for TLS 1.3, which defines elements for applying ShangMi algorithms over TLS 1.3. It complies IETF's Informational specification:
    • RFC 8998 ShangMi (SM) Cipher Suites for TLS 1.3

Providers and implementations

Tencent Kona JDK extends Java Cryptography Architecture (JCA) and Java Cryptography Extension (JCE) providers, exactly SUN, SunEC and SunJCE, to support ShangMi cryptographic algorithms, and extends Java Secure Socket Extension (JSSE) provider, exactly SunJSSE, to support ShangMi secure communication protocols.

The algorithms are implemented by the different security providers in the JDK. The followings list the security providers and the corresponding supported ShangMi algorithms and protocols.

  • SUN
    • MessageDigest
      • SM3
  • SunEC
    • KeyAgreement
      • SM2
    • KeyFactory
      • SM2
    • Signature
      • SM3withSM2
  • SunJCE
    • Cipher
      • SM4
    • KeyGenerator
      • HmacSM3
      • SM4
    • Mac
      • HmacSM3
  • SunJSSE
    • SSLContext
      • TLCP 1.1
        • ECC_SM4_GCM_SM3
        • ECC_SM4_CBC_SM3
        • ECDHE_SM4_GCM_SM3
        • ECDHE_SM4_CBC_SM3
      • TLS 1.3/RFC 8998
        • TLS_SM4_GCM_SM3

Since Tencent Kona JDK just uses the existing OpenJDK security providers to accommodate the ShangMi stuff, and these providers are already installed with the highest priorities, so the application developers can use these out-of-the-box features as those JDK built-in algorithms (e.g. EC and AES) and protocols (e.g. TLS 1.3).

The following sections will unveil the details on using the above algorithms and protocols.

SM2

Key pair

Generating SM2 key pair is the same as generating the key pairs on other EC curves. It just needs to invoke the standard JDK APIs. The JDK builtin ECKeyPairGenerator. In the key pair generated by this implementation, the format of private key is PKCS#8 and the format of public key is X.509.

Create KeyPairGenerator implementation for EC algorithm.

text
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC);
keyPairGenerator.initialize(spec);

spec can be SM2ParameterSpec (use SM2ParameterSpec.instance() to create the instance) or ECGenParameterSpec (use new ECGenParameterSpec("curveSM2") to create the instance).

Generate key pair.

text
KeyPair keyPair = keyPairGenerator.generateKeyPair();
ECPublicKey publicKey = (ECPublicKey) keyPair.getPublic();
ECPrivateKey privateKey = (ECPrivateKey) keyPair.getPrivate();

SM2 key pair is also EC key pair, so the public key and private key are also ECPublicKey and ECPrivateKey respectively.

For more information on key pair generation, please refer to the official KeyPairGenerator docs.

Generally, in the signing and encrypting operations, the key pairs are already generated. They are not generated on the runtime. It just reads the existing public key and private key to create PublicKey and PrivateKey instances respectively.

text
byte[] encodedPublicKey = ;
byte[] encodedPrivateKey = ;

KeyFactory keyFactory = KeyFactory.getInstance("SM2");

SM2PublicKeySpec publicKeySpec = new SM2PublicKeySpec(encodedPublicKey);
PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);

SM2PrivateKeySpec privateKeySpec = new SM2PrivateKeySpec(encodedPrivateKey);
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);

Signature

Using SM2 signature is the same as using other existing signatures, like ECDSA, though the parameters are different.

Create Signature instance.

text
Signature signature = Signature.getInstance("SM3withSM2);

Initialize the Signature instance with the private key for signing.

text
signature.initSign(privateKey);

Behind the above initialization, it uses the default SM2 ID, exactly 1234567812345678. It also derives the public key from the private key. According to the associated specification, public key must be used for generating SM2 signature data. This is a significant difference between the international algorithms, like ECDSA, and SM2 signature algorithm. Note that calculating the public key leads to some overhead. That is harmful for the performance.

If not using the default ID or expect to eliminate the cost on calculating public key, it would provide an AlgorithmParameterSpec, exactly SM2SignatureParameterSpec, instance.

text
byte[] altID = <custom ID>;
ECPublicKey publicKey = ;
SM2SignatureParameterSpec paramSpec = new SM2SignatureParameterSpec(altID, publicKey);
signature.setParameter(paramSpec);
signature.initSign(privateKey);

After parameter setup and initialization, it is time to pass the message data in.

text
byte[] message = ;
signature.update(message);

Generate signature data.

text
byte[] sign = signature.sign();

Initialize the Signature instance with public key for verifying.

text
signature.initVerify(publicKey);

Pass the message in.

text
byte[] message = ;
signature.update(message);

Pass the signature data in.

text
boolean verified = signature.verify(sign);

If the verification is successful, the result is true, otherwise false.

It has to know that the private key is used for signing, however the public key is used for verifying. For detailed information about Signature APIs, please refer to the official Signature docs.

Encryption

Because of the performance concern, public key encryption is only used for encrypting short but critical data. The same to SM2 encryption.

Create Cipher instance.

text
Cipher cipher = Cipher.getInstance("SM2");

Initialize the Cipher instance with public key and set the mode to encryption.

text
cipher.init(Cipher.ENCRYPT_MODE, publicKey);

Pass the message in and generate the ciphertext.

text
byte[] message = ;
byte[] ciphertext = cipher.doFinal(message);

Initialize the Cipher instance with private key and set the mode to decryption.

text
cipher.init(Cipher.DECRYPT_MODE, privateKey);

Pass the ciphertext in and generate the plaintext.

text
byte[] cleartext = cipher.doFinal(ciphertext);

It has to know that public key is used for encryption, however the private key is used for decryption. For detailed information on Cipher APIs, please refer to the official Cipher docs.

SM3

Using SM3 hash algorithm is the same as using other existing hash algorithm, like SHA-256. It only invokes JDK APIs to generate the message digest (hash).

Create MessageDigest instance.

text
MessageDigest md = MessageDigest.getInstance("SM3");

It can pass all the message in and generate the digest.

text
byte[] message = ;
byte[] digest = md.digest(message);

It also can pass the message segments, and finally generate the digest.

text
byte[] messageSegment1 = ;
byte[] messageSegment2 = ;

// Pass the message segments in
md.update(messageSegment1);
md.update(messageSegment2);

// Finally generate the digest
byte[] digest = md.digest();

For detailed information about MessageDigest APIs, please refer to the official MessageDigest docs.

HmacSM3

Using HmacSM3 algorithm is the same as using other existing MAC algorithm, like HmacSHA256. It only invokes JDK APIs to generate the message authentication code.

Prepare a 16-bytes key.

text
byte[] key = ;
SecretKey secretKey = new SecretKeySpec(key, "SM4");

Create Mac instance.

text
Mac hmac = Mac.getInstance("HmacSM3");

Initialize the Mac instance with the key.

text
hmac.init(secretKey);

Pass all the message in and generate message authentication code. The code is 32-bytes length.

text
byte[] message = ;
byte[] mac = hmac.doFinal(message);

It also can pass the message segments, and finally generate the message authentication code.

text
byte[] messageSegment1 = ;
byte[] messageSegment2 = ;

// Pass the message segments in
hmac.update(messageSegment1);
hmac.update(messageSegment2);

// Finally generate the message authentication code
byte[] mac = hmac.doFinal();

For the detailed information about Mac APIs, please refer to the official Mac docs.

SM4

Using SM4 cipher algorithm is the same as using other existing block cipher algorithm, like AES. It only invokes JDK APIs to do encryption and decryption. Tencent Kona JDK supports four operation modes, including CBC, CTR, ECB and GCM. It also supports PKCS#7 padding specification.

Prepare a 16-bytes key.

text
byte[] key = ;
SecretKey secretKey = new SecretKeySpec(key, "SM4");

Create Cipher instance.

text
Cipher cipher = Cipher.getInstance(transformation);

The transformation consists of algorithm name, operation mode and padding type. A symbol / is used as separator between the parts.

The following transformations are supported:

  • SM4/CBC/NoPadding: The operation mode is CBC. No padding is needed. It requires the input must be 16x bytes.
  • SM4/CBC/PKCS7Padding: The operation mode is CBC. PKCS#7 padding is used. It doesn't require that the input must be 16x bytes.
  • SM4/CTR/NoPadding: The operation mode is CBC. No padding is needed. It doesn't require that the input must be 16x bytes.
  • SM4/ECB/NoPadding: The operation mode is ECB. No padding is needed. It requires the input must be 16x bytes.
  • SM4/ECB/PKCS7Padding: The operation mode is ECB. PKCS#7 padding is used. It doesn't require that the input must be 16x bytes.
  • SM4/GCM/NoPadding: The operation mode is GCM. No padding is needed. It doesn't require that the input must be 16x bytes.

Create the algorithm parameters.

text
AlgorithmParameterSpec paramSpec = ;

Different operation modes may need different AlgorithmParameterSpec types,

  • CBC and CTR modes use IvParameterSpec. This parameter type needs a 16-bytes as Initialization Vector (IV).
  • GCM mode uses GCMParameterSpec. This parameter type needs a 12-bytes as Initialization Vector (IV) and specifies the tag length to 12-bytes.

Initialize the Cipher instance with the key and parameter type and set the mode to encryption.

text
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec);

Pass all the message in and generate the ciphertext.

text
byte[] ciphertext = cipher.doFinal(message);

Initialize the Cipher instance with the key and parameter type and set the mode to decryption.

text
cipher.init(Cipher.DECRYPT_MODE, secretKey);

Pass all the ciphertext in and generate the plaintext.

text
byte[] cleartext = cipher.doFinal(ciphertext);

It also can receive the plaintext/ciphertext segments in, and then generate the ciphertext/plaintext segments.

text
byte[] input1 = <segment1>;
byte[] input2 = <segment2>;

// Pass the plaintext/ciphertext segments in
byte[] output1 = cipher.update(input1);
byte[] output2 = cipher.update(input2);

// Generate the ciphertext/plaintext segments
byte[] outputFinal = cipher.doFinal();

For the detailed information about Cipher APIs, please refer to the official [Cipher] docs.

Certificate

The so-called ShangMi certificate also complies to X.509 specification, though the public key algorithm is EC with SM2 curve and the signature algorithm is SM3withSM2.

text
String certPEM = <certificate in PEM format>;
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) cf.generateCertificate(
        new ByteArrayInputStream(certPEM.getBytes(StandardCharsets.UTF_8));

For more information on certificate parsing, please read the official reference on CertificateFactory.

It can parse public key from the ShangMi certificate.

text
PublicKey publicKey = certificate.getPublicKey();

publicKey can be cast to ECPublicKey.

It can parse private key from PKCS#8 format.

text
String peyPEM = ;
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(
        Base64.getMimeDecoder().decode(keyPem));
KeyFactory keyFactory = KeyFactory.getInstance("EC");
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);

privateKey can be cast to ECPrivateKey.

It can sign data with PKCS#8 private key and verify the signature with X.509 certificate.

Create Signature instance and use SM3withSM2 signature algorithm.

text
Signature signature = Signature.getInstance("SM3withSM2");

Sign the message with the private key and generate the signature data.

text
signature.initSign(privateKey);
signature.update(message);
byte[] sign = signature.sign();

Verify the signature data with the certificate and determine whether the verification passes or fails.

text
signature.initVerify(certificate);
signature.update(message);
boolean verified = signature.verify(sign);

The certificate has to contain digitalSignature key usage for verifying signature data. But it also can verify the signature with the public key directly.

text
signature.initVerify(publicKey);
signature.update(message);
boolean verified = signature.verify(sign);

TLCP 1.1 and TLS 1.3/RFC 8998

In order to take advantage of the implementations on TLCP 1.1 and TLS 1.3/RFC 8998, the most important point is taking SSLSocket or SSLEngine to apply the SSLContext implementation that supports the protocols.

text
KeyStore trustStore = <a trust store carring the CAs>;
TrustManagerFactory tmf = TrustManagerFactory.getInstance("PKIX");
tmf.init(trustStore);

KeyStore keyStore = <a key store carring the end entity certificates>;
KeyManagerFactory kmf = KeyManagerFactory.getInstance("NewSunX509");
kmf.init(keyStore, keyStorePassword);

SSLContext context = SSLContext.getInstance("TLCPv1.1");
context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());

When create SSLContext instances, it allows to specify the following context protocols:

  • TLCPv1.1, which indicates only TLCP 1.1 is supported.
  • TLSv1.3, which indicates only TLS 1.3 is supported.
  • TLCP, which indicates TLCP 1.1, TLS 1.3 and TLS 1.2 are supported.

Please read the official JSSE reference for understanding it deeply.


File: konajdk/README.md

Tencent Kona

Tencent Kona is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support (LTS) with quarterly updates.

Kona serves as the default JDK at Tencent internally, optimized for extreme-scale of Big Data, Machine Learning and Cloud Computing workloads. It is also used to build and maintain a Tencent supported version of OpenJDK for Tencent customers and partners who wish to use OpenJDK to run their applications.

Kona also implements China's cryptographic algorithms, including SM2, SM3 and SM4, and secure communication protocol TLCP (or SMSSL). For more details on these features, please refer to the reference guide.

Supported JDK Releases

Tencent Kona currently supports the JDK Long-Term Support (LTS) releases 8, 11, 17, 21 and 25.
For more details, please go through the individual repository for each of these releases:

Supported System Platforms

Tencent Kona currently supports Linux/x86_64, Linux/aarch64, Windows/x86_64, macOS/x86_64 and macOS/aarch64.

License

Tencent Kona is under the same licensing terms as the upstream OpenJDK project. It is clearly a "friendly fork". Please find the license text for more details.