table_info.py
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#author: 4N
#createtime: 2021/1/27
#email: nheweijun@sina.com
from app.models import Table,Columns
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.ModelVisitor import ModelVisitor
class Api(ApiTemplate):
api_name = "表信息"
def process(self):
res = {}
try:
table_guid = self.para.get("guid")
table = Table.query.filter_by(guid=table_guid)
if not table.one_or_none():
raise Exception("数据不存在!")
table = table.one_or_none()
columns = table.relate_columns.order_by(Columns.name).all()
res["data"]=ModelVisitor.table_to_json(table)
res["data"]["columns"] = ModelVisitor.objects_to_jsonarray(columns)
res["result"] = True
except Exception as e:
raise e
return res
api_doc={
"tags":["管理接口"],
"parameters":[
{"name": "guid",
"in": "formData",
"type": "string",
"description": "表guid","required":"true"},
],
"responses":{
200:{
"schema":{
"properties":{
}
}
}
}
}