from utils.httputil import Http
from utils.dbQry import MyDbUtil
http = Http()
mydb = MyDbUtil()
def query_interface():
list = mydb.select_some("systems", "switch", 1)
nodes = mydb.select_some("node", "switch", 1)
tasks = mydb.select_some("task", "switch", 1)
apis = mydb.select_some("apis", "switch", 1)
if list:
treelist = []
for node in list:
system = {"sys_id": node.get("id"), "sys_name": node.get("name"), "children": []}
treelist.append(system)
for tl in treelist:
if nodes:
for node in nodes:
if tl.get('sys_id') == node.get('systems_id'):
node2 = {"node_id": node.get("id"), "node_name": node.get("name"), "children": []}
if tasks:
for task in tasks:
if node.get("id") == task.get('node_id'):
node3 = {"task_id": task.get("id"), "task_name": task.get("name"),
"task_result": task.get("expected"),
"expression": eval(task.get("expression")),
"frequency": task.get("frequency"), "children": []}
node2['children'].append(node3)
if apis:
for api in apis:
if task.get("id") == api.get("task_id"):
node4 = {"api_id": api.get("id"), "api_name": api.get("name"),
"method": api.get("method"), "url": api.get("url"),
"params": api.get("params")}
node3['children'].append(node4)
tl['children'].append(node2)
return treelist
else:
return None
# rs = http.doHttp(method=interface.get("method"), url=interface.get("url"), data=json.dumps(interface.get("params")))
# print("CCC",rs)
if __name__:
rs = query_interface()
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
