12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import requests
- from flask import request, jsonify
- from flask_restx import Resource, Namespace, reqparse
- from app.defines import StatesCode
- from app.utils.jwt_util import login_required
- from config import Config
- ns = Namespace('index', description='指标配置')
- config = Config()
- index_list = reqparse.RequestParser(bundle_errors=True)
- index_list.add_argument(name='page_size', type=int, location='args', required=False, help='每页记录数量,默认:20')
- index_list.add_argument(name='page', type=int, location='args', required=False, help='第几页')
- index_list.add_argument(name='parent_id', type=int, location='args', required=False, help='父id')
- @ns.route('/index_list')
- class IndexApi(Resource):
- # method_decorators = [login_required]
- @ns.doc(description='获取指标配置列表')
- @ns.expect(index_list)
- def get(self):
- parent_id = request.args.get('parent_id')
- page_size = int(request.args.get('page_size', 20))
- page = int(request.args.get('page', 1))
- if parent_id:
- parent_id = int(parent_id)
- params = {
- 'parentId': parent_id,
- 'page': page,
- 'pageSize': page_size
- }
- rep = requests.get(
- 'http://{host}:{post}/ioc-api/system_index/getIndexList'.format(host=config.system_monitoring.HOST,
- post=config.system_monitoring.POST
- ),
- params=params, headers={'clientId': "99"}).json()
- return jsonify(code=StatesCode.SUCCESS, message='成功', data=rep)
- get_system_menus_list = reqparse.RequestParser(bundle_errors=True)
- get_system_menus_list.add_argument(name='parentId', type=int, location='args', required=False)
- @ns.route('/get_system_menus_list')
- class SystemMenusListApi(Resource):
- @ns.doc(description='查询所有菜单')
- @ns.expect(get_system_menus_list)
- def get(self):
- """查询所有菜单"""
- parentId = request.args.get('parentId')
- if parentId:
- parentId = int(parentId)
- params = {
- 'parentId': parentId,
- }
- rep = requests.get(
- 'http://{host}:{post}/ioc-api/system_index/getSystemMenusList'.format(host=config.system_monitoring.HOST,
- post=config.system_monitoring.POST
- ),
- params=params, headers={'clientId': "99"}).json()
- return jsonify(code=StatesCode.SUCCESS, message='成功', data=rep)
|