mwgencode 1.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gencode/__init__.py +140 -0
- gencode/dd_models.py +256 -0
- gencode/ext.py +19 -0
- gencode/gen_code.py +343 -0
- gencode/gencode/__init__.py +0 -0
- gencode/gencode/export_class2swgclass.py +206 -0
- gencode/gencode/gen_bo_models_code.py +719 -0
- gencode/gencode/gen_state_code.py +171 -0
- gencode/gencode/gen_swagger_code.py +94 -0
- gencode/gencode/gen_tests_code.py +113 -0
- gencode/gencode/sample/__init__.py +2 -0
- gencode/gencode/sample/babel.cfg +3 -0
- gencode/gencode/sample/config-sample.ini +9 -0
- gencode/gencode/sample/config.ini +14 -0
- gencode/gencode/sample/create_new_table_run.pys +19 -0
- gencode/gencode/sample/dockerignore.dock +57 -0
- gencode/gencode/sample/file_utils.pys +396 -0
- gencode/gencode/sample/gencode.xmi +33 -0
- gencode/gencode/sample/gitignore.git +14 -0
- gencode/gencode/sample/migrate_run.bat +5 -0
- gencode/gencode/sample/migrate_run.pys +9 -0
- gencode/gencode/sample/requirements.txt +17 -0
- gencode/gencode/sample/run.sh +27 -0
- gencode/gencode/sample/seeds/__init__.py +0 -0
- gencode/gencode/sample/seeds/models_rm.pys +187 -0
- gencode/gencode/sample/seeds/seed_dev_data.pys +21 -0
- gencode/gencode/sample/seeds/seed_init.pys +17 -0
- gencode/gencode/sample/seeds/seed_rm.pys +39 -0
- gencode/gencode/sample/seeds/seed_run.pys +13 -0
- gencode/gencode/sample/seeds/seed_utils.pys +23 -0
- gencode/gencode/sample/test__init__.pys +6 -0
- gencode/gencode/sample/test_run.pys +4 -0
- gencode/gencode/sample/utils.pys +92 -0
- gencode/gencode/template/Dockerfile.tmp +55 -0
- gencode/gencode/template/README.md +91 -0
- gencode/gencode/template/__init__.py +0 -0
- gencode/gencode/template/__init__.pys +99 -0
- gencode/gencode/template/config.pys +134 -0
- gencode/gencode/template/default.conf +21 -0
- gencode/gencode/template/docker-compose-dev.yaml +52 -0
- gencode/gencode/template/docker-compose.yaml +55 -0
- gencode/gencode/template/drone.tmp +45 -0
- gencode/gencode/template/flask_models.pys +107 -0
- gencode/gencode/template/flask_models_base.pys +159 -0
- gencode/gencode/template/gen_code_flask.yaml +21 -0
- gencode/gencode/template/gen_code_run.pys +28 -0
- gencode/gencode/template/k8s-tmp.yml +141 -0
- gencode/gencode/template/run.pys +52 -0
- gencode/gencode/template/sample.mdj +1193 -0
- gencode/gencode/template/setup.tmp +48 -0
- gencode/gencode/template/supervisord.conf +21 -0
- gencode/gencode/template/swagger_file.yaml +195 -0
- gencode/gencode/template/swg_class.tmp +41 -0
- gencode/gencode/template/swg_ctrl_code.pys +130 -0
- gencode/gencode/template/swg_package_mng.tmp +4423 -0
- gencode/gencode/template/test_test_base.tmp +34 -0
- gencode/gencode/template/tests/__init__.py +0 -0
- gencode/gencode/template/tests/__init__.pys +5 -0
- gencode/gencode/template/tests/init_test_data.pys +80 -0
- gencode/gencode/template/tests/run.pys +4 -0
- gencode/gencode/template/tests/test_base.pys +87 -0
- gencode/gencode/template/tests/test_classmng.pys +58 -0
- gencode/gencode/template/uwsgi.ini +20 -0
- gencode/gencode/template/uwsgi_run.pys +44 -0
- gencode/importmdj/__init__.py +0 -0
- gencode/importmdj/import_dd_classes.py +369 -0
- gencode/importmdj/import_swagger2_class.py +371 -0
- gencode/importmdj/import_uml_models.py +466 -0
- gencode/importxmi/__init__.py +1 -0
- gencode/importxmi/import_classes.py +342 -0
- gencode/importxmi/import_sequences.py +291 -0
- gencode/importxmi/import_states.py +150 -0
- gencode/importxmi/import_swagger.py +151 -0
- gencode/swg2_class_models.py +179 -0
- gencode/uml_class_models.py +295 -0
- gencode/upgrade.py +113 -0
- gencode/utils.py +225 -0
- manage.py +194 -0
- mwgencode-1.4.1.dist-info/METADATA +325 -0
- mwgencode-1.4.1.dist-info/RECORD +84 -0
- mwgencode-1.4.1.dist-info/WHEEL +5 -0
- mwgencode-1.4.1.dist-info/entry_points.txt +2 -0
- mwgencode-1.4.1.dist-info/licenses/LICENSE.txt +19 -0
- mwgencode-1.4.1.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
try: # 导入模块
|
|
2
|
+
import xml.etree.cElementTree as ET
|
|
3
|
+
except ImportError:
|
|
4
|
+
import xml.etree.ElementTree as ET
|
|
5
|
+
|
|
6
|
+
uml="http://schema.omg.org/spec/UML/2.0"
|
|
7
|
+
xmi="{http://schema.omg.org/spec/XMI/2.1}"
|
|
8
|
+
_id = xmi+"id"
|
|
9
|
+
_type = xmi+"type"
|
|
10
|
+
_extension = xmi+'Extension'
|
|
11
|
+
|
|
12
|
+
class ImportStates():
|
|
13
|
+
def __init__(self):
|
|
14
|
+
self._objects = {}
|
|
15
|
+
self.states = []
|
|
16
|
+
self.trans = []
|
|
17
|
+
|
|
18
|
+
def _getDoc(self,attr):
|
|
19
|
+
extens = attr.find(_extension)
|
|
20
|
+
if extens is not None:
|
|
21
|
+
# print(' extens:',extens.attrib)
|
|
22
|
+
cls_doc = extens.find('documentation')
|
|
23
|
+
if cls_doc is not None:
|
|
24
|
+
return cls_doc.attrib.get('value')
|
|
25
|
+
return ''
|
|
26
|
+
|
|
27
|
+
def _handle_subv(self, subv, state):
|
|
28
|
+
# print('subv:',subv.attrib)
|
|
29
|
+
# if subv.attrib.get(_type,None) != 'uml:State':
|
|
30
|
+
# return None
|
|
31
|
+
region = subv.find('region', None)
|
|
32
|
+
if region:
|
|
33
|
+
self._handle_region(region, subv.attrib.get('name') + '_')
|
|
34
|
+
def getEnter(subv):
|
|
35
|
+
enters = subv.findall('entry')
|
|
36
|
+
result = []
|
|
37
|
+
for enter in enters:
|
|
38
|
+
result.append({'name':enter.attrib.get('name'),'doc':self._getDoc(enter)})
|
|
39
|
+
return result
|
|
40
|
+
|
|
41
|
+
def getExit(subv):
|
|
42
|
+
enters = subv.findall('exit')
|
|
43
|
+
result = []
|
|
44
|
+
for enter in enters:
|
|
45
|
+
result.append({'name': enter.attrib.get('name'), 'doc': self._getDoc(enter)})
|
|
46
|
+
return result
|
|
47
|
+
return {'type':'state', 'id':subv.attrib.get(_id),
|
|
48
|
+
'name':subv.attrib.get('name'),'doc':self._getDoc(subv),
|
|
49
|
+
'onenter':getEnter(subv),'onexit':getExit(subv)}
|
|
50
|
+
|
|
51
|
+
def _handle_tran(self, tran):
|
|
52
|
+
def getTriger(tran):
|
|
53
|
+
trgs = tran.findall('trigger')
|
|
54
|
+
for trg in trgs:
|
|
55
|
+
if trg.attrib.get(_type)=='uml:Trigger':
|
|
56
|
+
if trg.attrib.get('name') != '':
|
|
57
|
+
return trg.attrib.get('name')
|
|
58
|
+
# 如果没有trigger则直接返回tran的name
|
|
59
|
+
result = tran.attrib.get('name').split('(')[0]
|
|
60
|
+
if result:
|
|
61
|
+
return result
|
|
62
|
+
|
|
63
|
+
def getGuard(tran):
|
|
64
|
+
guard = tran.find('guard')
|
|
65
|
+
if guard is not None:
|
|
66
|
+
result = guard.attrib.get('specification')
|
|
67
|
+
if result is not None:
|
|
68
|
+
return result
|
|
69
|
+
return ''
|
|
70
|
+
|
|
71
|
+
def getBefore(tran):
|
|
72
|
+
result = tran.attrib.get('name',None)
|
|
73
|
+
if result:
|
|
74
|
+
return result
|
|
75
|
+
return ''
|
|
76
|
+
|
|
77
|
+
def getEffect(tran):
|
|
78
|
+
effe = tran.find('effect')
|
|
79
|
+
# print(tran.attrib)
|
|
80
|
+
if effe is not None:
|
|
81
|
+
result = effe.attrib.get('name')
|
|
82
|
+
if result is not None:
|
|
83
|
+
return result
|
|
84
|
+
return ''
|
|
85
|
+
# print(tran.attrib)
|
|
86
|
+
try:
|
|
87
|
+
return {'trigger': getTriger(tran),
|
|
88
|
+
'doc': self._getDoc(tran),
|
|
89
|
+
'source': self._objects[tran.attrib.get('source')]['name'],
|
|
90
|
+
'target': self._objects[tran.attrib.get('target')]['name'],
|
|
91
|
+
'guard': getGuard(tran),
|
|
92
|
+
'before':getBefore(tran),
|
|
93
|
+
'after': getEffect(tran)}
|
|
94
|
+
except Exception as e:
|
|
95
|
+
# print('--------------',tran.attrib)
|
|
96
|
+
# print('--------------',e)
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
# print('tran:',tran.attrib)
|
|
100
|
+
|
|
101
|
+
def _handle_region(self, region, state=''):
|
|
102
|
+
state_d = {}
|
|
103
|
+
for subv in region.findall('subvertex'):
|
|
104
|
+
if subv.attrib.get(_type, None) != 'uml:State':
|
|
105
|
+
continue
|
|
106
|
+
state_o = self._handle_subv(subv, state)
|
|
107
|
+
if state_o is not None:
|
|
108
|
+
self._objects[state_o['id']] = state_o
|
|
109
|
+
state_d.setdefault(state + 'states',[]).append(state_o)
|
|
110
|
+
if state_d:
|
|
111
|
+
self.states.append(state_d)
|
|
112
|
+
|
|
113
|
+
for tran in region.findall('transition'):
|
|
114
|
+
if tran.attrib.get(_type) != 'uml:Transition':
|
|
115
|
+
continue
|
|
116
|
+
tran_o = self._handle_tran(tran)
|
|
117
|
+
if tran_o:
|
|
118
|
+
self.trans.append(tran_o)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _handle_pkgElm(self, pkgElms):
|
|
122
|
+
for pkg in pkgElms:
|
|
123
|
+
if pkg.attrib.get(_type, None) != 'uml:StateMachine':
|
|
124
|
+
continue
|
|
125
|
+
region = pkg.find('region',None)
|
|
126
|
+
if region is None :
|
|
127
|
+
continue
|
|
128
|
+
self._handle_region(region)
|
|
129
|
+
|
|
130
|
+
def impxml(self,file):
|
|
131
|
+
self._objects = {}
|
|
132
|
+
self.states = []
|
|
133
|
+
self.trans = []
|
|
134
|
+
tree = ET.parse(file) # 分析XML文件
|
|
135
|
+
root = tree.getroot()
|
|
136
|
+
# print('0', root)
|
|
137
|
+
for idx0,r in enumerate(root):
|
|
138
|
+
# print('%d'%idx0, r.attrib)
|
|
139
|
+
if r.attrib.get('name', None) != 'RootModel':
|
|
140
|
+
continue
|
|
141
|
+
self._handle_pkgElm(r.findall('packagedElement'))
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if __name__ == '__main__':
|
|
145
|
+
i = ImportStates()
|
|
146
|
+
i.impxml(r"D:\mwwork\projects\iparking\docs-parking\parking-state.xml")
|
|
147
|
+
# print(i._objects)
|
|
148
|
+
# print(i.states)
|
|
149
|
+
print(i.trans)
|
|
150
|
+
# i.impxml(r"test.xml")
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
try: # 导入模块
|
|
2
|
+
import xml.etree.cElementTree as ET
|
|
3
|
+
except ImportError:
|
|
4
|
+
import xml.etree.ElementTree as ET
|
|
5
|
+
|
|
6
|
+
from mwutils.utils import none2default
|
|
7
|
+
from gencode import (ImportBase,uml,xmi,_id,_type,_extension
|
|
8
|
+
)
|
|
9
|
+
class ImportSwagger(ImportBase):
|
|
10
|
+
def __init__(self):
|
|
11
|
+
self.swagger= {'title':'swagger','version':'v1.0','doc':'please add swagger package to uml'}
|
|
12
|
+
self.packages = []
|
|
13
|
+
self.objects_bo = {}
|
|
14
|
+
self.datatypes = []
|
|
15
|
+
self.singals = []
|
|
16
|
+
self.pts = []
|
|
17
|
+
self.classes = []
|
|
18
|
+
|
|
19
|
+
def _handle_swagger(self, pkg_swg):
|
|
20
|
+
# 记录swagger package 信息
|
|
21
|
+
self.swagger['title'], self.swagger['version'],*_ = \
|
|
22
|
+
none2default(self.get_stereotype(pkg_swg), ['swagger', 'v1.0'])
|
|
23
|
+
self.swagger['resp_xml'] = 'xml' in self.get_stereotype(pkg_swg)
|
|
24
|
+
self.swagger['doc'] = self.get_doc(pkg_swg)
|
|
25
|
+
pkgs = pkg_swg.findall('packagedElement')
|
|
26
|
+
def set_lk_flag(op):
|
|
27
|
+
'''
|
|
28
|
+
给lk关联的datatype打上lk的标志,便于产生lk的datatype
|
|
29
|
+
:param id:
|
|
30
|
+
:return:
|
|
31
|
+
'''
|
|
32
|
+
def set_flg(obj,type):
|
|
33
|
+
for attr in obj['attrs']:
|
|
34
|
+
if attr['type'] == 'object':
|
|
35
|
+
obj_attr = self.objects_bo[attr['typename']]
|
|
36
|
+
if obj_attr['type'] not in ('uml:DataType', 'uml:Class'):
|
|
37
|
+
raise Exception('[%s.%s]的类型必须为:DataType 或Class'
|
|
38
|
+
% (obj['name'],attr['name']))
|
|
39
|
+
# 返回的类型只能允许result和return的attr才要做lookup
|
|
40
|
+
if type=='return' and attr['name'] not in ('result','return'):
|
|
41
|
+
continue
|
|
42
|
+
obj_attr['haslkobj'] = True
|
|
43
|
+
for dt in self.datatypes:
|
|
44
|
+
if dt['id']==attr['typename']:
|
|
45
|
+
dt['haslkobj'] = True
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
in_obj = self.objects_bo[op['in']['typename']]
|
|
50
|
+
set_flg(in_obj,'in')
|
|
51
|
+
except Exception as e:
|
|
52
|
+
raise Exception('[%s.%s.%s] 发生错误, error:%s'%(op['pkg_name'],op['name'],in_obj['name'],e))
|
|
53
|
+
try:
|
|
54
|
+
return_obj = self.objects_bo[op['return']['typename']]
|
|
55
|
+
set_flg(return_obj,'return')
|
|
56
|
+
except Exception as e:
|
|
57
|
+
raise Exception('[%s.%s.%s] 发生错误, error:%s' % (op['pkg_name'],op['name'], return_obj['name'], e))
|
|
58
|
+
|
|
59
|
+
def add_datatype(pkg_dt):
|
|
60
|
+
if pkg_dt.attrib.get(_type, None) == 'uml:DataType':
|
|
61
|
+
datatype = self.get_bo_class(pkg_dt)
|
|
62
|
+
datatype['haslkobj'] = self.objects_bo[pkg_dt.attrib.get(_id)].get('haslkobj', False)
|
|
63
|
+
self.datatypes.append(datatype)
|
|
64
|
+
elif pkg_dt.attrib.get(_type, None) == 'uml:Signal':
|
|
65
|
+
signal = self.get_bo_class(pkg_dt)
|
|
66
|
+
signal['pkg_name'] = pkg.attrib.get('name')
|
|
67
|
+
ops_lk = []
|
|
68
|
+
for op in signal['ops']:
|
|
69
|
+
op['pkg_name'] = signal['pkg_name']
|
|
70
|
+
if 'lk' in op['stereotype']:
|
|
71
|
+
op_cp = op.copy()
|
|
72
|
+
op['stereotype'].remove('lk')
|
|
73
|
+
op_cp['stereotype'] = ['lk']
|
|
74
|
+
op_cp['name']='%s_%s'%(op['name'],'lk')
|
|
75
|
+
ops_lk.append(op_cp)
|
|
76
|
+
# 给op关联的物件设为lk
|
|
77
|
+
set_lk_flag(op)
|
|
78
|
+
signal['ops'].extend(ops_lk)
|
|
79
|
+
self.singals.append(signal)
|
|
80
|
+
elif pkg_dt.attrib.get(_type, None) == 'uml:PrimitiveType':
|
|
81
|
+
# self.objects_bo['AAAAAAFeCiNYUToFjYA=']
|
|
82
|
+
self.pts.append(self.get_bo_class(pkg_dt))
|
|
83
|
+
elif pkg_dt.attrib.get(_type, None) == 'uml:Class':
|
|
84
|
+
datatype = self.get_bo_class(pkg_dt)
|
|
85
|
+
datatype['haslkobj'] = self.objects_bo[pkg_dt.attrib.get(_id)].get('haslkobj',False)
|
|
86
|
+
self.datatypes.append(datatype)
|
|
87
|
+
# self.pts.append(self.get_bo_class(pkg_dt))
|
|
88
|
+
# def add_datatype_from_pts():
|
|
89
|
+
# '''
|
|
90
|
+
# 把不在swagger下的class加到datatypes中,以便能正确的产生swagger类
|
|
91
|
+
# :return:
|
|
92
|
+
# '''
|
|
93
|
+
# for pt in self.pts:
|
|
94
|
+
# for attr in pt.get('attrs',[]):
|
|
95
|
+
# if attr['type']=='object':
|
|
96
|
+
# ref_class = self.objects_bo[attr['typename']]
|
|
97
|
+
# for datatype in self.datatypes:
|
|
98
|
+
# if datatype['id']==ref_class['id']:
|
|
99
|
+
# break
|
|
100
|
+
# else:
|
|
101
|
+
# self.datatypes.append(ref_class)
|
|
102
|
+
#
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# swagger下的每个package是一个tag
|
|
106
|
+
for pkg in pkgs:
|
|
107
|
+
package = {'name':pkg.attrib.get('name'), 'doc':self.get_doc(pkg)}
|
|
108
|
+
# 只允许容器类才能加入
|
|
109
|
+
if pkg.attrib.get(_type, None) in['uml:Package','uml:Model','uml:Component']:
|
|
110
|
+
self.packages.append(package)
|
|
111
|
+
else:
|
|
112
|
+
add_datatype(pkg)
|
|
113
|
+
pkgs_datatype = pkg.findall('packagedElement')
|
|
114
|
+
for pkg_dt in pkgs_datatype:
|
|
115
|
+
add_datatype(pkg_dt)
|
|
116
|
+
# 增加不在swagger package中的类
|
|
117
|
+
# add_datatype_from_pts()
|
|
118
|
+
|
|
119
|
+
def _handle_pkgElm(self, pkgElms):
|
|
120
|
+
for pkg in pkgElms:
|
|
121
|
+
# 记录swagger信息
|
|
122
|
+
if pkg.attrib.get('name', None) != 'swagger' :
|
|
123
|
+
continue
|
|
124
|
+
self.swagger['title'],self.swagger['version'],*_ = \
|
|
125
|
+
self.get_stereotype(pkg)
|
|
126
|
+
self.swagger['doc'] = self.get_doc(pkg)
|
|
127
|
+
self._handle_swagger(pkg)
|
|
128
|
+
|
|
129
|
+
def impxml(self,file):
|
|
130
|
+
tree = ET.parse(file) # 分析XML文件
|
|
131
|
+
root = tree.getroot()
|
|
132
|
+
for idx0,r in enumerate(root):
|
|
133
|
+
if r.attrib.get('name', None) != 'RootModel':
|
|
134
|
+
continue
|
|
135
|
+
# 加入所有的数据类型的class
|
|
136
|
+
for bo_cls in self.find_bo_classes(r):
|
|
137
|
+
self.objects_bo[bo_cls['id']]=(self.get_bo_class(bo_cls['obj']))
|
|
138
|
+
# 处理所有package
|
|
139
|
+
self._handle_pkgElm(r.findall('packagedElement'))
|
|
140
|
+
|
|
141
|
+
if __name__ == '__main__':
|
|
142
|
+
i = ImportSwagger()
|
|
143
|
+
i.impxml(r"D:\mwwork\projects\its\mobile_gateway_server\docs\uml analyse.xml")
|
|
144
|
+
# print(i.trans)
|
|
145
|
+
# print(i.objects_pkg)
|
|
146
|
+
print('swagger',i.swagger)
|
|
147
|
+
print('datatypes',i.datatypes)
|
|
148
|
+
print('singals',i.singals)
|
|
149
|
+
print('p', i.pts)
|
|
150
|
+
# i.impxml(r"test.xml")
|
|
151
|
+
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
########################################
|
|
2
|
+
# create by :cxh-pc
|
|
3
|
+
# create time :2018-04-26 20:44:57.895581
|
|
4
|
+
########################################
|
|
5
|
+
from sqlalchemy import Table,Column, Integer, String, ForeignKey, Boolean,\
|
|
6
|
+
DateTime,Time,Date,Float
|
|
7
|
+
from sqlalchemy.orm import relationship,aliased
|
|
8
|
+
from sqlalchemy import or_
|
|
9
|
+
from .ext import Base as Model
|
|
10
|
+
import json
|
|
11
|
+
from enum import Enum
|
|
12
|
+
class Swagger2(Model):
|
|
13
|
+
__tablename__ = 'swagger2'
|
|
14
|
+
name = Column(String(50), unique= True)
|
|
15
|
+
host = Column(String(50))
|
|
16
|
+
version = Column(String(50))
|
|
17
|
+
id = Column(String(50), primary_key=True)
|
|
18
|
+
resp_xml = Column(Boolean)
|
|
19
|
+
resp_html = Column(Boolean)
|
|
20
|
+
doc = Column(String(50))
|
|
21
|
+
auth = Column(String(50), default= "jwt")
|
|
22
|
+
tags = relationship("Tag2", back_populates="swagger", foreign_keys="Tag2.swaggerid", cascade="all, delete-orphan")
|
|
23
|
+
defines = relationship("Define2", back_populates="swagger", foreign_keys="Define2.swaggerid", cascade="all, delete-orphan")
|
|
24
|
+
def __repr__(self):
|
|
25
|
+
return json.dumps(self.to_json())
|
|
26
|
+
def to_json(self):
|
|
27
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
28
|
+
if hasattr(self,key)
|
|
29
|
+
}
|
|
30
|
+
class Tag2(Model):
|
|
31
|
+
__tablename__ = 'tag2'
|
|
32
|
+
name = Column(String(50), unique= True)
|
|
33
|
+
doc = Column(String(50))
|
|
34
|
+
id = Column(String(50), primary_key=True)
|
|
35
|
+
swaggerid = Column(String(50),ForeignKey("swagger2.id"), nullable= False)
|
|
36
|
+
swagger = relationship("Swagger2", back_populates="tags", foreign_keys="Tag2.swaggerid")
|
|
37
|
+
paths = relationship("Path2", back_populates="tag", foreign_keys="Path2.tagid", cascade="all, delete-orphan")
|
|
38
|
+
def call_path(self):
|
|
39
|
+
return self.name
|
|
40
|
+
def __repr__(self):
|
|
41
|
+
return json.dumps(self.to_json())
|
|
42
|
+
def to_json(self):
|
|
43
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
44
|
+
if hasattr(self,key)
|
|
45
|
+
}
|
|
46
|
+
class Action2(Model):
|
|
47
|
+
"""
|
|
48
|
+
把path归于tag下,更易于产生代码
|
|
49
|
+
"""
|
|
50
|
+
__tablename__ = 'action2'
|
|
51
|
+
action = Column(String(50))
|
|
52
|
+
summary = Column(String(50))
|
|
53
|
+
doc = Column(String(50))
|
|
54
|
+
ver_str = Column(String(50))
|
|
55
|
+
has_formdata = Column(Boolean)
|
|
56
|
+
id = Column(String(50), primary_key=True)
|
|
57
|
+
is_lk = Column(Boolean, default= False)
|
|
58
|
+
# stereotype 包含 lk ,如:get/lk
|
|
59
|
+
include_lk = Column(Boolean, default= False)
|
|
60
|
+
# 有page过滤条件
|
|
61
|
+
has_page = Column(Boolean, default= False)
|
|
62
|
+
in_param_name = Column(String(50))
|
|
63
|
+
return_param_name = Column(String(50))
|
|
64
|
+
# 需要认证
|
|
65
|
+
is_auth = Column(Boolean, default= False)
|
|
66
|
+
auth_type = Column(String(50))
|
|
67
|
+
pathid = Column(Integer,ForeignKey("path2.id"), nullable= False)
|
|
68
|
+
default_respid = Column(Integer,ForeignKey("resp2.id"))
|
|
69
|
+
path = relationship("Path2", back_populates="actions", foreign_keys="Action2.pathid")
|
|
70
|
+
default_resp = relationship("Resp2", foreign_keys="Action2.default_respid")
|
|
71
|
+
params = relationship("Param2", back_populates="action", foreign_keys="Param2.actionid", cascade="all, delete-orphan")
|
|
72
|
+
resps = relationship("Resp2", back_populates="action", foreign_keys="Resp2.actionid", cascade="all, delete-orphan")
|
|
73
|
+
def call_path(self):
|
|
74
|
+
return '%s.%s'%(self.path.call_path(),self.action)
|
|
75
|
+
def __repr__(self):
|
|
76
|
+
return json.dumps(self.to_json())
|
|
77
|
+
def to_json(self):
|
|
78
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
79
|
+
if hasattr(self,key)
|
|
80
|
+
}
|
|
81
|
+
class Param2(Model):
|
|
82
|
+
__tablename__ = 'param2'
|
|
83
|
+
in_ = Column(String(50))
|
|
84
|
+
name = Column(String(50))
|
|
85
|
+
desc = Column(String(50))
|
|
86
|
+
required = Column(Boolean)
|
|
87
|
+
is_array = Column(Boolean)
|
|
88
|
+
type_attr = Column(String(50))
|
|
89
|
+
type = Column(String(50))
|
|
90
|
+
format = Column(String(50))
|
|
91
|
+
ref_name = Column(String(50))
|
|
92
|
+
id = Column(Integer, primary_key=True)
|
|
93
|
+
is_path = Column(Boolean, default= False)
|
|
94
|
+
is_header = Column(Boolean, default= False)
|
|
95
|
+
is_body = Column(Boolean, default= False)
|
|
96
|
+
is_query = Column(Boolean, default= False)
|
|
97
|
+
is_formdata = Column(Boolean, default= False)
|
|
98
|
+
actionid = Column(String(50),ForeignKey("action2.id"), nullable= False)
|
|
99
|
+
action = relationship("Action2", back_populates="params", foreign_keys="Param2.actionid")
|
|
100
|
+
def call_path(self):
|
|
101
|
+
return '%s.%s'%(self.action.call_path(),self.name)
|
|
102
|
+
def __repr__(self):
|
|
103
|
+
return json.dumps(self.to_json())
|
|
104
|
+
def to_json(self):
|
|
105
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
106
|
+
if hasattr(self,key)
|
|
107
|
+
}
|
|
108
|
+
class Resp2(Model):
|
|
109
|
+
__tablename__ = 'resp2'
|
|
110
|
+
code = Column(String(50))
|
|
111
|
+
desc = Column(String(50))
|
|
112
|
+
type_attr = Column(String(50))
|
|
113
|
+
is_array = Column(Boolean)
|
|
114
|
+
ref_name = Column(String(50), default= '')
|
|
115
|
+
type = Column(String(50))
|
|
116
|
+
id = Column(Integer, primary_key=True)
|
|
117
|
+
format = Column(String(50))
|
|
118
|
+
# 记录引用物件的类型
|
|
119
|
+
umlcls_type = Column(String(50))
|
|
120
|
+
name = Column(String(50), default= '')
|
|
121
|
+
actionid = Column(String(50),ForeignKey("action2.id"), nullable= False)
|
|
122
|
+
action = relationship("Action2", back_populates="resps", foreign_keys="Resp2.actionid")
|
|
123
|
+
def call_path(self):
|
|
124
|
+
return '%s.%s'%(self.action.call_path(),self.name)
|
|
125
|
+
def __repr__(self):
|
|
126
|
+
return json.dumps(self.to_json())
|
|
127
|
+
def to_json(self):
|
|
128
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
129
|
+
if hasattr(self,key)
|
|
130
|
+
}
|
|
131
|
+
class Define2(Model):
|
|
132
|
+
__tablename__ = 'define2'
|
|
133
|
+
name = Column(String(50), unique= True)
|
|
134
|
+
desc = Column(String(50))
|
|
135
|
+
id = Column(String(50), primary_key=True)
|
|
136
|
+
is_lk = Column(Boolean, default= False)
|
|
137
|
+
swaggerid = Column(String(50),ForeignKey("swagger2.id"), nullable= False)
|
|
138
|
+
swagger = relationship("Swagger2", back_populates="defines", foreign_keys="Define2.swaggerid")
|
|
139
|
+
attrs = relationship("Attr2", back_populates="define", foreign_keys="Attr2.defineid", cascade="all, delete-orphan")
|
|
140
|
+
def __repr__(self):
|
|
141
|
+
return json.dumps(self.to_json())
|
|
142
|
+
def to_json(self):
|
|
143
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
144
|
+
if hasattr(self,key)
|
|
145
|
+
}
|
|
146
|
+
class Attr2(Model):
|
|
147
|
+
__tablename__ = 'attr2'
|
|
148
|
+
name = Column(String(50))
|
|
149
|
+
is_array = Column(Boolean)
|
|
150
|
+
desc = Column(String(50))
|
|
151
|
+
type_attr = Column(String(50))
|
|
152
|
+
type = Column(String(50))
|
|
153
|
+
format = Column(String(50))
|
|
154
|
+
id = Column(Integer, primary_key=True)
|
|
155
|
+
ref_name = Column(String(50))
|
|
156
|
+
defineid = Column(String(50),ForeignKey("define2.id"), nullable= False)
|
|
157
|
+
define = relationship("Define2", back_populates="attrs", foreign_keys="Attr2.defineid")
|
|
158
|
+
def __repr__(self):
|
|
159
|
+
return json.dumps(self.to_json())
|
|
160
|
+
def to_json(self):
|
|
161
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
162
|
+
if hasattr(self,key)
|
|
163
|
+
}
|
|
164
|
+
class Path2(Model):
|
|
165
|
+
__tablename__ = 'path2'
|
|
166
|
+
name = Column(String(50))
|
|
167
|
+
id = Column(Integer, primary_key=True)
|
|
168
|
+
is_lk = Column(Boolean, default= False)
|
|
169
|
+
tagid = Column(String(50),ForeignKey("tag2.id"), nullable= False)
|
|
170
|
+
tag = relationship("Tag2", back_populates="paths", foreign_keys="Path2.tagid")
|
|
171
|
+
actions = relationship("Action2", back_populates="path", foreign_keys="Action2.pathid", cascade="all, delete-orphan")
|
|
172
|
+
def call_path(self):
|
|
173
|
+
return '%s.%s'%(self.tag.call_path(),self.name)
|
|
174
|
+
def __repr__(self):
|
|
175
|
+
return json.dumps(self.to_json())
|
|
176
|
+
def to_json(self):
|
|
177
|
+
return {key: getattr(self, key) for key in self.__table__.columns.keys()
|
|
178
|
+
if hasattr(self,key)
|
|
179
|
+
}
|