Commit b5d5d2cf authored by 金凯强's avatar 金凯强 🎨

受黄总压迫增加分页

parent 94f5c4ca
......@@ -5,75 +5,75 @@ import requests
if __name__ == '__main__':
data = {'user_name': 'jkq', 'password': 'jkq_test'}
# 设置登录信息
requests.post('http://localhost:5000/authorization/',json=data)
# 登录
res = requests.post('http://localhost:5000/authorization/login/',json=data)
print(res.json())
# # 设置登录信息
# requests.post('http://localhost:5000/authorization/',json=data)
#
# # 登录
# res = requests.post('http://localhost:5000/authorization/login/',json=data)
# print(res.json())
#
# 获取项目链接
res = requests.get('http://localhost:5000/connection/')
print(res.json())
json_data = {"project_no": "jkq_test", "db_ip": "47.97.206.38", "db_port": "9610", "db_user": "huansi",
"db_password": "huansi", "mes_db_name": "HSGmtMes", "tiip_db_name": "HSTIIP",
"host_ip": "192.168.4.116","id":"1237937496479928320"}
# 设置项目链接
res = requests.post('http://localhost:5000/connection/', json=json_data)
print(res.json())
# 测试项目数据库连接
res = requests.get('http://localhost:5000/connection/jkq_test/HSGmtMEs/')
print(res.json())
json_data = {"project_no": "jkq_test", "server_ip": "192.168.4.116", "server_ssh_port": "1111",
"server_user": "root",
"server_password": "huansi.net","id":1237968030966910976}
# 设置远程服务器连接
res = requests.post('http://localhost:5000/connection/remote_server/', json=json_data)
print(res.json())
#
# json_data = {"project_no": "jkq_test", "db_ip": "47.97.206.38", "db_port": "9610", "db_user": "huansi",
# "db_password": "huansi", "mes_db_name": "HSGmtMes", "tiip_db_name": "HSTIIP",
# "host_ip": "192.168.4.116","id":"1237937496479928320"}
#
# # 设置项目链接
# res = requests.post('http://localhost:5000/connection/', json=json_data)
# print(res.json())
#
# # 测试项目数据库连接
# res = requests.get('http://localhost:5000/connection/jkq_test/HSGmtMEs/')
# print(res.json())
#
# json_data = {"project_no": "jkq_test", "server_ip": "192.168.4.116", "server_ssh_port": "1111",
# "server_user": "root",
# "server_password": "huansi.net","id":1237968030966910976}
#
# # 设置远程服务器连接
# res = requests.post('http://localhost:5000/connection/remote_server/', json=json_data)
# print(res.json())
#
# 获取远程服务器连接
res = requests.get('http://localhost:5000/connection/remote_server/')
print(res.json())
# 测试端口是否开放
res = requests.get('http://localhost:5000/connection/test_port/23002/')
print(res.json())
# 获取app_list
res = requests.get('http://localhost:5000/info/app_list/')
print(json.dumps(res.json(), indent=4))
# 配置app升级信息
json_data = [
{"app_code": "rabbitMQ", "app_name": "rabbitMQ", "app_image": "47.110.145.204:8084/huansi/mq:latest"},
{"app_code": "Redis", "app_name": "Redis", "app_image": "47.110.145.204:8084/huansi/redis:latest"},
{"app_code": "Tool", "app_name": "tools工具集", "app_image": "47.110.145.204:8084/huansi/hs_tools:1.1"}]
res = requests.post('http://localhost:5000/info/app_upgrade/', json=json_data)
print(res.json())
# 获取app升级日志列表
res = requests.get('http://localhost:5000/info/upgrade_log/')
print(json.dumps(res.json(), indent=4))
# 获取app单次升级日志明细
res = requests.get('http://localhost:5000/info/upgrade_log_dtl/1237995081698545664/')
print(json.dumps(res.json(), indent=4))
# 安装runner
res = requests.get('http://localhost:5000/install/runner/')
print(json.dumps(res.json(), indent=4))
# 回滚升级
res = requests.get('http://localhost:5000/upgrade/rollback/1238022723059486720/')
print(json.dumps(res.json(), indent=4))
# 远程升级
res = requests.get('http://localhost:5000/upgrade/remote/')
print(json.dumps(res.json(), indent=4))
#
# # 测试端口是否开放
# res = requests.get('http://localhost:5000/connection/test_port/23002/')
# print(res.json())
#
# # 获取app_list
# res = requests.get('http://localhost:5000/info/app_list/')
# print(json.dumps(res.json(), indent=4))
#
# # 配置app升级信息
# json_data = [
# {"app_code": "rabbitMQ", "app_name": "rabbitMQ", "app_image": "47.110.145.204:8084/huansi/mq:latest"},
# {"app_code": "Redis", "app_name": "Redis", "app_image": "47.110.145.204:8084/huansi/redis:latest"},
# {"app_code": "Tool", "app_name": "tools工具集", "app_image": "47.110.145.204:8084/huansi/hs_tools:1.1"}]
#
# res = requests.post('http://localhost:5000/info/app_upgrade/', json=json_data)
# print(res.json())
#
# # 获取app升级日志列表
# res = requests.get('http://localhost:5000/info/upgrade_log/')
# print(json.dumps(res.json(), indent=4))
#
#
# # 获取app单次升级日志明细
# res = requests.get('http://localhost:5000/info/upgrade_log_dtl/1237995081698545664/')
# print(json.dumps(res.json(), indent=4))
#
# # 安装runner
# res = requests.get('http://localhost:5000/install/runner/')
# print(json.dumps(res.json(), indent=4))
#
# # 回滚升级
# res = requests.get('http://localhost:5000/upgrade/rollback/1238022723059486720/')
# print(json.dumps(res.json(), indent=4))
#
# # 远程升级
# res = requests.get('http://localhost:5000/upgrade/remote/')
# print(json.dumps(res.json(), indent=4))
......@@ -30,7 +30,8 @@ class InfoAPI(ApiController):
获取app升级日志列表
:return:
'''
return InfoService().get_upgrade_log()
args = request.args
return InfoService().get_upgrade_log(args)
@api('upgrade_log_dtl/<int:log_id>')
def get_upgrade_log_dtl(self, log_id):
......@@ -39,4 +40,5 @@ class InfoAPI(ApiController):
:param log_id:
:return:
'''
return InfoService().get_upgrade_log_dtl(log_id)
args = request.args
return InfoService().get_upgrade_log_dtl(log_id, args)
......@@ -135,49 +135,72 @@ values
return {'message': '写入成功'}
def get_upgrade_log(self):
def get_upgrade_log(self, args):
'''
获取升级历史信息
:return:
'''
per_page = args.get('per_page',10)
page = args.get('page',1)
offset = (int(page) - 1) * int(per_page)
sql = '''select A.*,(select count(*) from app_upgrade_log_dtl where log_id=A.id) as count
from app_upgrade_log A
order by A.default_version desc, A.upgrade_time desc
limit {},{}
'''.format(offset, per_page)
count_sql = '''select count(*) as count
from app_upgrade_log A
order by A.default_version desc, A.upgrade_time desc
'''
with db_driver as session:
data = session.query_sql(sql)
count_data = session.retrive_sql(count_sql)
page_data = {
"paging": {
"page": 1,
"per_page": 10,
"total": 10
"page": page,
"per_page": per_page,
"total": count_data['count'] if count_data else 0
},
"table": data
"table": data if data else []
}
return page_data
def get_upgrade_log_dtl(self, log_id):
def get_upgrade_log_dtl(self, log_id, args):
'''
获取升级历史信息详情
:param log_id:
:return:
'''
per_page = args.get('per_page',10)
page = args.get('page',1)
offset = (int(page) - 1) * int(per_page)
sql = f'''select A.*
from app_upgrade_log_dtl A
where A.log_id={log_id}
limit {offset},{per_page}
'''
count_sql = f'''select count(*) as count
from app_upgrade_log_dtl A
where A.log_id={log_id}'''
with db_driver as session:
data = session.query_sql(sql)
count_data = session.retrive_sql(count_sql)
page_data = {
"paging": {
"page": 1,
"per_page": 10,
"total": 10
"page": page,
"per_page": per_page,
"total": count_data['count'] if count_data else 0
},
"table": data
"table": data if data else []
}
return page_data
......@@ -45,7 +45,7 @@ class TestGetInfo(unittest.TestCase):
print(res.json)
def test_get_upgrade_log_dtl(self):
log_id = 1237310513316270080
res = self.client.get('/info/upgrade_log_dtl/{}/'.format(log_id))
log_id = 1238385199009665024
res = self.client.get('/info/upgrade_log_dtl/{}/?per_page=2&page=2'.format(log_id))
self.assertEqual(res.status_code, 200)
print(res.json)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment