Skip to content

Commit 6eed78b

Browse files
committed
update document and screenshot
1 parent 14d8d16 commit 6eed78b

File tree

2 files changed

+9
-159
lines changed

2 files changed

+9
-159
lines changed

demo/doc/imgs/demo_screenshot.png

21.3 KB
Loading

uliweb_apijson/apijson/README.md

+9-159
Original file line numberDiff line numberDiff line change
@@ -9,174 +9,24 @@ uliweb-apijson is a subset and slightly different variation of [apijson](https:/
99
```
1010
[APIJSON_MODEL_CONFIG]
1111
user = {
12-
"public" : False,
1312
"user_id_field" : "id",
1413
"secret_fields" : ["password"],
15-
"default_filter_by_self" : True
14+
"rbac_get" : {
15+
"roles" : ["ADMIN","OWNER"]
16+
}
1617
}
1718
```
1819

1920
## document
2021

2122
settings.APIJSON_MODEL_CONFIG.[MODEL_NAME]
2223

23-
| Field | Doc |
24-
| ---------------------- | ------------------------------------------------------------ |
25-
| public | Default to be "False".<br />If not public, should be **login user** and only can see **user own data**. |
26-
| user_id_field | Field name of user id, related to query user own data. |
27-
| secret_fields | Secret fields won't be exposed. |
28-
| default_filter_by_self | If True, when no filter parameter, will filter by self user id |
24+
| Field | Doc |
25+
| ------------- | ---------------------------------------------------------- |
26+
| user_id_field | Field name of user id, related to query user own data. |
27+
| secret_fields | Secret fields won't be exposed. |
28+
| rbac_get | Configure of roles or permissions for apijson 'get' method |
2929

3030
# Supported API Examples
3131

32-
### Single record query: with id as parameter
33-
34-
URL: apijson/get
35-
36-
Method: POST
37-
38-
Request:
39-
40-
```
41-
{
42-
"user":{
43-
"id":1
44-
}
45-
}
46-
```
47-
48-
Response:
49-
50-
```
51-
{
52-
"code": 200,
53-
"msg": "success",
54-
"user": {
55-
"username": "usera",
56-
"nickname": "User A",
57-
"email": "usera@localhost",
58-
"is_superuser": false,
59-
"last_login": null,
60-
"date_join": "2018-12-05 15:44:26",
61-
"image": "",
62-
"active": false,
63-
"locked": false,
64-
"deleted": false,
65-
"auth_type": "default",
66-
"id": 1
67-
}
68-
}
69-
```
70-
71-
### Single record query: no parameter
72-
73-
URL: apijson/get
74-
75-
Method: POST
76-
77-
Request:
78-
79-
```
80-
{
81-
"user":{
82-
}
83-
}
84-
```
85-
86-
Response:
87-
88-
```
89-
{
90-
"code": 200,
91-
"msg": "success",
92-
"user": {
93-
"username": "usera",
94-
"nickname": "User A",
95-
"email": "usera@localhost",
96-
"is_superuser": false,
97-
"last_login": null,
98-
"date_join": "2018-12-05 15:44:26",
99-
"image": "",
100-
"active": false,
101-
"locked": false,
102-
"deleted": false,
103-
"auth_type": "default",
104-
"id": 1
105-
}
106-
}
107-
```
108-
109-
### Single record query: @column
110-
111-
URL: apijson/get
112-
113-
Method: POST
114-
115-
Request:
116-
117-
```
118-
{
119-
"user":{
120-
"@column": "id,username,email"
121-
}
122-
}
123-
```
124-
125-
Response:
126-
127-
```
128-
{
129-
"code": 200,
130-
"msg": "success",
131-
"user": {
132-
"username": "usera",
133-
"email": "usera@localhost",
134-
"id": 1
135-
}
136-
}
137-
```
138-
139-
### Array query
140-
141-
URL: apijson/get
142-
143-
Method: POST
144-
145-
Request:
146-
147-
```
148-
{
149-
"[]":{
150-
"@count":2,
151-
"@page":0,
152-
"user":{
153-
"@column":"id,username,nickname,email",
154-
"@order":"id-"
155-
}
156-
}
157-
}
158-
```
159-
160-
Response:
161-
162-
```
163-
{
164-
"code": 200,
165-
"msg": "success",
166-
"[]": [
167-
{
168-
"username": "userc",
169-
"nickname": "User C",
170-
"email": "userc@localhost",
171-
"id": 3
172-
},
173-
{
174-
"username": "userb",
175-
"nickname": "User B",
176-
"email": "userb@localhost",
177-
"id": 2
178-
}
179-
]
180-
}
181-
```
182-
32+
Please run [demo](../../demo/README.md) project and try it.

0 commit comments

Comments
 (0)