Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sync#30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
TommyLemon merged 5 commits intoAPIJSON:masterfromzhangchunlin:master
May 31, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ uliweb-apijson 是 APIJSON 的 Python 版后端实现,基于 uliweb 框架。
APIJSON
</h1>

<p align="center">码云最有价值开源项目<br />后端接口和文档自动化,前端(客户端) 定制返回JSON的数据和结构!</p>
<p align="center">🏆码云最有价值开源项目<br />🚀后端接口和文档自动化,前端(客户端) 定制返回JSON的数据和结构!</p>

<p align="center" >
<a href="https://github.com/TommyLemon/APIJSON/tree/master/MySQL"><img src="https://img.shields.io/badge/MySQL-5.7%2B-brightgreen.svg?style=flat"></a>
Expand Down
2 changes: 1 addition & 1 deletiondemo/apps/apijson_demo/views.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,7 +106,7 @@ def index():
"@column":"id,username,nickname,email",
"@order":"id-",
"@role":"ADMIN",
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],,
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],
"username$":"%b%",
"nickname$":"%Admin%",
"email$":"%local%"
Expand Down
1 change: 1 addition & 0 deletionssetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,6 +38,7 @@ def grep(attrname):
author_email=grep('__email__'),
description='uliweb-apijson',
long_description=desc(),
long_description_content_type="text/markdown",
packages = find_packages(),
include_package_data=True,
zip_safe=False,
Expand Down
2 changes: 1 addition & 1 deletionuliweb_apijson/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
__version__ = '0.1.1'
__version__ = '0.1.2'
__url__ = 'https://github.com/zhangchunlin/uliweb-apijson'
__author__ = 'Chunlin Zhang'
__email__ = 'zhangchunlin@gmail.com'
62 changes: 60 additions & 2 deletionsuliweb_apijson/apijson/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,15 @@

uliweb-apijson is a subset and slightly different variation of [apijson](https://github.com/TommyLemon/APIJSON/blob/master/Document.md)

# Difference with original apijson

| feature | apijson(java) | uliweb-apijson | comment |
| -------- | ------------- | -------------- | ------------------------------------------------------------ |
| @combine | ✔️ | ✖️ | Example: "@combine":"&key0,&key1,\|key2,key3" |
| @expr | ✖️ | ✔️ | Example: "@expr":[["username$","&","email$"],"&",["!","nickname$"]] |



# apijson model configuration

## example
Expand All@@ -13,9 +22,16 @@ user = {
"secret_fields" : ["password"],
"GET" : { "roles" : ["ADMIN","OWNER"] },
"HEAD" : { "roles" : ["ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
usergroup = {
"GET" : { "roles" : ["ADMIN","LOGIN"] },
"HEAD" : { "roles" : ["ADMIN"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
```

Expand DownExpand Up@@ -58,6 +74,48 @@ request types currently support: POST, PUT

request configuration currently support: ADD,DISALLOW,NECESSARY (still not fully support [all the configuration items](https://github.com/TommyLemon/APIJSON/wiki#%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86))

# apijson table configuration

## example

```
[APIJSON_TABLES]
roles = {
"@model_name" : "role",
"editable" : "auto",
"table_fields" : [
{"title":"#","key":"id","width":80,"component":"id"},
{"title":"Name","key":"name","component":"name_link"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
"viewedit_fields" : [
{"title":"#","key":"id","editable":False},
{"title":"Name","key":"name"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
"add_fields" : [
{"title":"Name","key":"name"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
}
```

## document

Provide 2 vue component about table:

| | apijson-table | apijson-viewedit |
| ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| uliweb template include | {{include "vue/inc_apijson_table.html"}} | {{include "vue/inc_apijson_viewedit.html"}} |
| example: | ```<apijson-table model_name="permission" :config="tconfig" :custom_tcolumns_render_generator="custom_tcolumns_render_generator" ref="table"></apijson-table>``` | ```<apijson-viewedit model_name="permission" request_tag="{{=request_tag}}" :id="id_" :config="tconfig"></apijson-viewedit>``` |






# Supported API Examples

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@
"request_tag",
"id",
"config",
"custom_tcolumns_render_generator",
"hook_init",
"hook_ajax_params"
],
Expand All@@ -16,6 +15,7 @@
<i-input v-if="item.component=='input'" v-model="item.value" :readonly="!editable(item)"></i-input>
<checkbox v-if="item.component=='checkbox'" v-model="item.value" :disabled="!editable(item)"></checkbox>
<i-input v-if="item.component=='textarea'" v-model="item.value" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></i-input>
{{block custom_viewedit_componet}}{{end custom_viewedit_componet}}
</form-item>
<form-item v-if="config_editable" label="Action">
<i-button type="info" icon="ios-download" size="large" @click="save">Save</i-button>
Expand Down
6 changes: 3 additions & 3 deletionsuliweb_apijson/apijson/views.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ def __begin__(self):
log.error("try to load json but get exception: '%s', request data: %s"%(e,request.data))
return json({"code":400,"msg":"not json data in the request"})

defapply_vars(self):
def_apply_vars(self):
for key in self.request_data:
if key[-1]=="@":
k = self.request_data[key]
Expand All@@ -42,12 +42,12 @@ def get(self):
else:
rsp = self._get_one(key)
if rsp: return rsp
self.apply_vars()
self._apply_vars()
except Exception as e:
err = "exception when handling 'apijson get': %s"%(e)
log.error(err)
traceback.print_exc()
return json({"code":400,"msg":err})
return json({"code":400,"msg":"get exception when handling 'apijson get',please check server side log"})
return json(self.rdict)

def _get_one(self,key):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp