类图
├── JSON.java
├── JSONObject.java
├── JSONRequest.java
├── JSONResponse.java
├── Log.java
├── MethodAccess.java
├── NotNull.java
├── orm
│ ├── AbstractFunctionParser.java 函数解析
│ ├── AbstractObjectParser.java Object解析
│ ├── AbstractParser.java 抽象出来的解析类,看具体的类图
│ ├── AbstractSQLConfig.java SQL配置类
│ ├── AbstractSQLExecutor.java SQL执行器
│ ├── AbstractVerifier.java SQL验证器
│ ├── Entry.java
│ ├── exception
│ │ ├── ConditionErrorException.java
│ │ ├── ConflictException.java
│ │ ├── NotExistException.java
│ │ ├── NotLoggedInException.java
│ │ ├── OutOfRangeException.java
│ │ └── package-info.java
│ ├── FunctionParser.java
│ ├── Join.java
│ ├── JSONRequest.java
│ ├── Logic.java
│ ├── model
│ │ ├── Access.java
│ │ ├── Column.java
│ │ ├── Document.java
│ │ ├── ExtendedProperty.java
│ │ ├── Function.java
│ │ ├── package-info.java
│ │ ├── PgAttribute.java
│ │ ├── PgClass.java
│ │ ├── Request.java
│ │ ├── Response.java
│ │ ├── SysColumn.java
│ │ ├── SysTable.java
│ │ ├── Table.java
│ │ ├── Test.java
│ │ └── TestRecord.java
│ ├── ObjectParser.java interface AbstractObjectParser实现它
│ ├── OnParseCallback.java
│ ├── Operation.java
│ ├── package-info.java
│ ├── Pair.java
│ ├── ParserCreator.java
│ ├── Parser.java interface AbstractParser 实现它
│ ├── SQLConfig.java interface 与sql语句的中间层 AbstractSQLConfig 实现
│ ├── SQLCreator.java
│ ├── SQLExecutor.java
│ ├── Structure.java
│ ├── Subquery.java
│ ├── VerifierCreator.java
│ ├── Verifier.java
│ └── Visitor.java
├── package-info.java
├── RequestMethod.java
├── RequestRole.java 请求方法 get/post/head/delete
├── SQL.java ?
└── StringUtil.java 字符串工具类
执行的大概流程
[AbstractParser.java line 311 ] public JSONObject parseResponse(JSONObject request) {
接收一个JOSON,然后对其解析
--> [AbstractParser.java line 373 ] requestObject = onObjectParse(request, null, null, null, false); 这个函数真正的执行了解析JSON
---->[AbstractParser.java line 770] public JSONObject onObjectParse(final JSONObject request 把子对传给它
createObjectParse 是在apijson-framwork里重写了这个接口函数
--- > [AbstractObjectParser.java line 163] public AbstractObjectParser parse() throws Exception { 进行正式的解析
- istable
- method == PUT
[ AbstractObjectParser.java line 235 ]response.put(key, onChildParse(index, key, (JSONObject)value)); 调用onChildeProcess
-> [AbstractObjectParser.java 445 ] public JSON onChildParse(int index, String key, JSONObject value) throws Exception {
-isArraykey
-istableKey
parser.onObjectParse -> {id: 12} name='key'
--- > [AbstractObjectParser.java line 163] public AbstractObjectParser parse() throws Exception { 进行正式的解析
--- > [AbstractObjectParser.java line 299] public boolean onParse(@NotNull String key, @NotNull Object value) throws Exception {
endwith @
endwith ()
istable && startwith @
op
setSQLConfig
excuteSQL
onSQLExecute();
[AbstractParser.java line 1444] public JSONObject executeSQL(SQLConfig config, boolean isSubquery) throws Exception {
> [1476] result = getSQLExecutor().execute(config, false);
[ AbstractSQLExecutor line 150 ] public JSONObject execute(@NotNull SQLConfig config, boolean unknowType) throws Exception {
config.getSQL config 转成 sql 语句
rs.executeQuery(config)
[ AbstractSQLExecutor 768] getStatement(config).executeQuery() 到这里相当于执行了sql语句
```
核心的 创建一个sqlconfig [AbstractSQLConfig line 2570 ]public static SQLConfig newSQLConfig(RequestMethod method, String table, String alias, JSONObject request, List joinList, boolean isProcedure, Callback callback) throws Exception { if (request == null) { // User:{} 这种空内容在查询时也有效
+------------------+ | 客户端发送的JSON | //这里开始解析 得到 parser对象 +------------------+ ObjectParser op = createObjectParser(request, parentPath, name, arrayConfig, isSubquery).parse();// 创建了一个ObjectParse,并解析,得到结果 | | op对象 setSQLConfig().executeSQL() v +---------+ | request | +---------+ | | v +-----------+ | SQLConfig | +-----------+ final String sql = config.getSQL(false);
parse
onObjectParse
onChildParse
onArrayParse
## 查询的分类
```plaintext
onParse
key.endsWith('@')
- value instanceof JSONObject 子查询
'id@' :{
from:'Comment',
'@Column':'min(userId)'
}
- value instanceof String 引用赋值路径
key.endsWith('()') 远程函数调用
isTable && key.startswith("@") JSONRequest.TABLE_KEY_LIST.contains(key) == false
customMap.put @Column 类似的自定义的关键字
else
sqlRequest.put(key, value);
onChildParse
- array -onArrayParse
- table -onObjectParse
"[]" : {
user[] : {
}
}