Skip to content

Commit fb2dbe3

Browse files
authored
调整全能 CRUD 文档:修改错误、优化 JSON 格式、标记弃用第二种方式 @method
1 parent f39d269 commit fb2dbe3

File tree

1 file changed

+51
-34
lines changed

1 file changed

+51
-34
lines changed

Diff for: README-extend.md

+51-34
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,23 @@ https://github.com/Tencent/APIJSON/issues/468
66

77
#### 使用说明
88

9-
json支持多种方式定义method
9+
json 支持多种方式定义 method
1010

11-
第一种:
11+
#### 第一种:
1212

13-
"@post","@put","@delete","@head","@get","@gets","@head","@heads"
13+
"@post","@put","@delete","@head","@get","@gets","@head","@heads"
1414

15-
"@post": ["Moment","Comment[]"] , 值为数组格式, 每个value = key
15+
"@post": "Moment,Comment[]" , 值为 String 或 JSONObject 格式, 为 String 时每个 value = key,为 JSONObject 时:
16+
```json
17+
"@post": {
18+
"Moment": "Moment", // 只指定 tag,为 "" 则和 key 一致
19+
"Comment[]": { // 同时指定多个全局关键词
20+
"tag": "Comment[]",
21+
"version": 2
22+
// 其它全局关键词
23+
}
24+
}
25+
```
1626

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

@@ -24,7 +34,7 @@ key= Moment[]
2434

2535
```
2636
{
27-
"@post": ["Moment","Comment:cArray[]","User:u"], // 分发到 POST 请求对应的解析处理
37+
"@post": "Moment,Comment:cArray[],User:u", // 分发到 POST 请求对应的解析处理
2838
"Moment": {
2939
// TODO 其它字段
3040
},
@@ -33,7 +43,7 @@ key= Moment[]
3343
// TODO 其它字段
3444
}
3545
],
36-
"@get": ["User"], // 分发到 GET 请求对应的解析处理
46+
"@get": "User", // 分发到 GET 请求对应的解析处理
3747
"User:u": {
3848
// TODO 其它字段
3949
},
@@ -46,19 +56,19 @@ key= Moment[]
4656
4757
```
4858

49-
第二种:
59+
#### 第二种: @Deprecated 即将弃用,请使用第一种
5060

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

5363
```
5464
{
55-
"sql@": {
65+
"sql@": {
5666
"@method": "GET",
5767
"with": true,
5868
"from": "Sys_role",
5969
"Sys_role": {
60-
"@column": "id",
61-
"role_name": "角色1"
70+
"@column": "id",
71+
"role_name": "角色1"
6272
}
6373
},
6474
"Sys_user_role:sur[]": {
@@ -152,14 +162,14 @@ Comment:cArray[]
152162

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

155-
```
165+
```json
156166
"Sys_role": {
157-
"@method": "PUT",
158-
"id": "6aedce0d-2a29-4fbe-aeed-0ba935ca6b41",
159-
"id{}@": "sql",
160-
"role_code": "code-subrange-4",
161-
"role_name": "角色-subrange-4"
162-
}
167+
"@method": "PUT",
168+
"id": "6aedce0d-2a29-4fbe-aeed-0ba935ca6b41",
169+
"id{}@": "sql",
170+
"role_code": "code-subrange-4",
171+
"role_name": "角色-subrange-4"
172+
}
163173
```
164174

165175
2、对象解析
@@ -741,15 +751,18 @@ AbstractVerifier.IS_UPDATE_MUST_HAVE_ID_CONDITION = true; // true: 必须有
741751

742752
```
743753
// 条件删除
754+
```json
744755
{
745756
"User:del": {
746757
"username": "test3"
747758
},
748759
"tag": "User",
749760
"explain": true
750761
}
762+
```
751763

752764
// 引用id{}@删除
765+
```json
753766
{
754767
"sql@": {
755768
"@method": "GET",
@@ -766,8 +779,11 @@ AbstractVerifier.IS_UPDATE_MUST_HAVE_ID_CONDITION = true; // true: 必须有
766779
},
767780
"explan": true
768781
}
782+
```
783+
769784
// 子查询条件删除
770785
http://localhost:8675/lowCodePlatform/forms/api/delete
786+
```json
771787
{
772788
"sql@": {
773789
"@method": "GET",
@@ -783,8 +799,10 @@ http://localhost:8675/lowCodePlatform/forms/api/delete
783799
},
784800
"explan": true
785801
}
802+
```
786803

787804
第二种写法:
805+
```json
788806
{
789807
"@get": ["sql@"],
790808
"sql@": {
@@ -800,23 +818,21 @@ http://localhost:8675/lowCodePlatform/forms/api/delete
800818
},
801819
"explan": true
802820
}
803-
804-
805821
```
806822

807823

808824

809825
开启id删除, 删除失败:
810826

811-
```
827+
```json
812828
{
813-
"@get": ["sql@"],
814-
"sql@": {
829+
"@get": ["sql@"],
830+
"sql@": {
815831
"with": true,
816832
"from": "User",
817833
"User": {
818-
"@column": "username",
819-
"username": "test4"
834+
"@column": "username",
835+
"username": "test4"
820836
}
821837
},
822838
"User": {
@@ -830,7 +846,7 @@ http://localhost:8675/lowCodePlatform/forms/api/delete
830846

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

833-
```
849+
```json
834850
{
835851
"sql@": {
836852
"@method": "GET",
@@ -848,19 +864,20 @@ http://localhost:8675/lowCodePlatform/forms/api/delete
848864
"explan": true
849865
}
850866
```
867+
851868
![image](https://user-images.githubusercontent.com/12228225/204080050-e6f04fe6-319e-45b7-b1b2-bf4cda4ab2db.png)
852869

853870
PUT 子查询 修改
854871

855-
```
872+
```json
856873
{
857874
"sql@": {
858-
"@method": "GET",
875+
"@method": "GET",
859876
"with": true,
860877
"from": "Sys_role_permission",
861878
"Sys_role_permission": {
862-
"@column": "role_id",
863-
"id{}": ["ba2634f8-0bdc-4b50-9c5e-47786b1536ef"]
879+
"@column": "role_id",
880+
"id{}": ["ba2634f8-0bdc-4b50-9c5e-47786b1536ef"]
864881
}
865882
},
866883
"Sys_role": {
@@ -892,15 +909,15 @@ WHERE ( (`username` IN (SELECT * FROM (SELECT `username` FROM `housekeeping`.`Us
892909

893910
### must、refuses判断、delete、PUT支持 ref
894911

895-
```
912+
```json
896913
{
897-
"sql@": {
898-
"@method": "GET",
914+
"sql@": {
915+
"@method": "GET",
899916
"with": true,
900917
"from": "Sys_role_permission",
901918
"Sys_role_permission": {
902-
"@column": "id",
903-
"role_id{}": ["94f79f0b-331b-4cc5-bfc0-ebfc47d00f13"]
919+
"@column": "id",
920+
"role_id{}": ["94f79f0b-331b-4cc5-bfc0-ebfc47d00f13"]
904921
}
905922
},
906923
"Sys_role_permission": {

0 commit comments

Comments
 (0)