通用文档:新增对万能通用 API 对应数据库增删改查的 SQL 说明
This commit is contained in:
parent
41fedcfe75
commit
22d1861739
10
Document.md
10
Document.md
@ -330,13 +330,13 @@
|
||||
|
||||
方法及说明 | URL | Request | Response
|
||||
------------ | ------------ | ------------ | ------------
|
||||
GET: <br > 普通获取数据,<br > 可用浏览器调试 | base_url/get/ | {<br > TableName:{<br > … <br > }<br >} <br > {…}内为限制条件<br ><br > 例如获取一个 id = 235 的 Moment:<br >{<br > "Moment":{<br > "id":235<br > }<br >} | {<br > TableName:{<br > ...<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Moment":{<br > "id":235,<br > "userId":38710,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "code":200,<br > "msg":"success"<br > }
|
||||
HEAD: <br > 普通获取数量,<br > 可用浏览器调试 | base_url/head/ | {<br > TableName:{<br > …<br > }<br > } <br > {…}内为限制条件 <br ><br > 例如获取一个 id = 38710 的 User 所发布的 Moment 总数:<br >{<br > "Moment":{<br > "userId":38710<br > }<br >} | {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "count":10<br > },<br > "code":200,<br > "msg":"success"<br >} <br > 例如<br >{<br > "Moment":{<br > "code":200,<br > "msg":"success",<br > "count":10<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
GET: <br > 普通获取数据,<br > 可用浏览器调试 | base_url/get/ | {<br > TableName:{<br > … <br > }<br >} <br > {…}内为限制条件<br ><br > 例如获取一个 id = 235 的 Moment:<br >{<br > "Moment":{<br > "id":235<br > }<br >} <br > 后端校验通过后自动解析为 SQL 并执行:<br >`SELECT * FROM Moment WHERE id=235 LIMIT 1` | {<br > TableName:{<br > ...<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Moment":{<br > "id":235,<br > "userId":38710,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "code":200,<br > "msg":"success"<br > }
|
||||
HEAD: <br > 普通获取数量,<br > 可用浏览器调试 | base_url/head/ | {<br > TableName:{<br > …<br > }<br > } <br > {…}内为限制条件 <br ><br > 例如获取一个 id = 38710 的 User 所发布的 Moment 总数:<br >{<br > "Moment":{<br > "userId":38710<br > }<br >} <br > 后端校验通过后自动解析为 SQL 并执行:<br >`SELECT count(*) FROM Moment WHERE userId=38710 LIMIT 1` | {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "count":10<br > },<br > "code":200,<br > "msg":"success"<br >} <br > 例如<br >{<br > "Moment":{<br > "code":200,<br > "msg":"success",<br > "count":10<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
GETS: <br > 安全/私密获取数据,<br > 用于获取钱包等<br >对安全性要求高的数据 | base_url/gets/ | 最外层加一个 "tag":tag,其它同GET | 同GET
|
||||
HEADS: <br > 安全/私密获取数量,<br > 用于获取银行卡数量等<br >对安全性要求高的数据总数 | base_url/heads/ | 最外层加一个 "tag":tag,其它同HEAD | 同HEAD
|
||||
POST: <br > 新增数据 | base_url/post/ | 单个: <br > {<br > TableName:{<br > …<br > },<br > "tag":tag<br >} <br > {…}中id由后端生成,不能传 <br ><br >例如一个 id = 38710 的 User 发布一个新 Moment:<br >{<br > "Moment":{<br > "userId":38710,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "tag":"Moment"<br >}<br > <br > 批量: <br > {<br > TableName\[]:\[{<br > …<br > }, {<br > …<br > }<br > …<br > ],<br > "tag":tag<br >} <br > {…}中id由后端生成,不能传 <br ><br >例如当前登录用户 82001 发布 2 个 Comment:<br >{<br > "Comment\[]":\[{<br > "momentId":12,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > }, {<br > "momentId":15,<br > "content":"APIJSON is a JSON transmision protocol."<br > }],<br > "tag":"Comment[]"<br >}<br > | 单个: <br > {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "id":38710<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Moment":{<br > "code":200,<br > "msg":"success",<br > "id":120<br > },<br > "code":200,<br > "msg":"success"<br >} <br > <br > 批量: <br > {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "count":5,<br > "id[]":[1, 2, 3, 4, 5]<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Comment":{<br > "code":200,<br > "msg":"success",<br > "count":2,<br > "id[]":\[1, 2]<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
PUT: <br > 修改数据,<br > 只修改所传的字段 | base_url/put/ | {<br > TableName:{<br > "id":id,<br > …<br > },<br > "tag":tag<br >} <br > {…} 中 id 或 id{} 至少传一个 <br ><br >例如修改 id = 235 的 Moment 的 content:<br >{<br > "Moment":{<br > "id":235,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "tag":"Moment"<br >} <br > <br > 批量除了 id{}:\[] 也可类似批量 POST,只是每个 {...} 里面都必须有 id | 同POST
|
||||
DELETE: <br > 删除数据 | base_url/delete/ | {<br > TableName:{<br > "id":id<br > },<br > "tag":tag<br >} <br > {…} 中 id 或 id{} 至少传一个,一般只传 id 或 id{} <br ><br >例如批量删除 id = 100,110,120 的 Comment:<br >{<br > "Comment":{<br > "id{}":[100,110,120]<br > },<br > "tag":"Comment[]"<br >} | {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "id[]":[100,110,120]<br > "count":3<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Comment":{<br > "code":200,<br > "msg":"success",<br > "id[]":[100,110,120],<br > "count":3<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
POST: <br > 新增数据 | base_url/post/ | 单个: <br > {<br > TableName:{<br > …<br > },<br > "tag":tag<br >} <br > {…}中id由后端生成,不能传 <br ><br >例如一个 id = 38710 的 User 发布一个新 Moment:<br >{<br > "Moment":{<br > "userId":38710,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "tag":"Moment"<br >} <br > 后端校验通过后自动解析为 SQL 并执行:<br >`INSERT INTO Moment(userId,content) VALUES(38710,'APIJSON,let interfaces and documents go to hell !')` <br > <br > 批量: <br > {<br > TableName\[]:\[{<br > …<br > }, {<br > …<br > }<br > …<br > ],<br > "tag":tag<br >} <br > {…}中id由后端生成,不能传 <br ><br >例如当前登录用户 82001 发布 2 个 Comment:<br >{<br > "Comment\[]":\[{<br > "momentId":12,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > }, {<br > "momentId":15,<br > "content":"APIJSON is a JSON transmision protocol."<br > }],<br > "tag":"Comment[]"<br >}<br > 后端校验通过后自动解析为 SQL 并执行:<br >`INSERT INTO Comment(userId,momentId,content) VALUES(82001,12,'APIJSON,let interfaces and documents go to hell !')`<br >`INSERT INTO Comment(userId,momentId,content) VALUES(82001,15,'APIJSON is a JSON transmision protocol.')` | 单个: <br > {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "id":38710<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Moment":{<br > "code":200,<br > "msg":"success",<br > "id":120<br > },<br > "code":200,<br > "msg":"success"<br >} <br > <br > 批量: <br > {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "count":5,<br > "id[]":[1, 2, 3, 4, 5]<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Comment":{<br > "code":200,<br > "msg":"success",<br > "count":2,<br > "id[]":\[1, 2]<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
PUT: <br > 修改数据,<br > 只修改所传的字段 | base_url/put/ | {<br > TableName:{<br > "id":id,<br > …<br > },<br > "tag":tag<br >} <br > {…} 中 id 或 id{} 至少传一个 <br ><br >例如修改 id = 235 的 Moment 的 content:<br >{<br > "Moment":{<br > "id":235,<br > "content":"APIJSON,let interfaces and documents go to hell !"<br > },<br > "tag":"Moment"<br >} <br > 后端校验通过后自动解析为 SQL 并执行:<br >`UPDATE Moment SET content='APIJSON,let interfaces and documents go to hell !' WHERE id=235 AND userId=82001 LIMIT 1` <br > 批量除了 id{}:\[] 也可类似批量 POST,只是每个 {...} 里面都必须有 id | 同POST
|
||||
DELETE: <br > 删除数据 | base_url/delete/ | {<br > TableName:{<br > "id":id<br > },<br > "tag":tag<br >} <br > {…} 中 id 或 id{} 至少传一个,一般只传 id 或 id{} <br ><br >例如批量删除 id = 100,110,120 的 Comment:<br >{<br > "Comment":{<br > "id{}":[100,110,120]<br > },<br > "tag":"Comment[]"<br >} <br > 后端校验通过后自动解析为 SQL 并执行:<br >`DELETE FROM Comment WHERE id IN(100,110,120) AND userId=82001 LIMIT 3` | {<br > TableName:{<br > "code":200,<br > "msg":"success",<br > "id[]":[100,110,120]<br > "count":3<br > },<br > "code":200,<br > "msg":"success"<br >}<br >例如<br >{<br > "Comment":{<br > "code":200,<br > "msg":"success",<br > "id[]":[100,110,120],<br > "count":3<br > },<br > "code":200,<br > "msg":"success"<br >}
|
||||
|
||||
|
||||
1.TableName指要查询的数据库表Table的名称字符串。第一个字符为大写字母,剩下的字符要符合英语字母、数字、下划线中的任何一种。对应的值的类型为JSONObject,结构是 {...},里面放的是Table的字段(列名)。下同。<br >
|
||||
|
Loading…
Reference in New Issue
Block a user