field_list.py
1.6 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
46
47
48
49
50
51
52
53
54
55
56
57
58
#author: 4N
#createtime: 2021/1/27
#email: nheweijun@sina.com
import traceback
from ..models import Table
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.ModelVisitor import ModelVisitor
class Api(ApiTemplate):
api_name = "属性列表"
def process(self):
#返回结果
dir_path = None
res={}
try:
table_guid = self.para.get("guid")
is_for_partition = self.para.get("is_for_partition")
table:Table = Table.query.filter_by(guid=table_guid).one_or_none()
if table:
res["result"]=True
res["data"] = ModelVisitor.objects_to_jsonarray(table.relate_columns)
if is_for_partition:
res["data"] = [data for data in res["data"] if data["is_for_partition"] == int(is_for_partition)]
else:
res["result"]=False
res["msg"] = "数据表不存在!"
except Exception as e:
print(traceback.format_exc())
raise e
return res
api_doc={
"tags":["管理接口"],
"parameters":[
{"name": "guid",
"in": "formData",
"type": "string",
"description": "表guid"},
{"name": "is_for_partition",
"in": "formData",
"type": "int",
"description": "是否用于分层分级", "enum": [0, 1]},
],
"responses":{
200:{
"schema":{
"properties":{
}
}
}
}
}