diff --git a/Modules/Functions/FinIndex/FinIndexImpl.py b/Modules/Functions/FinIndex/FinIndexImpl.py index fbea51d..a7cac79 100644 --- a/Modules/Functions/FinIndex/FinIndexImpl.py +++ b/Modules/Functions/FinIndex/FinIndexImpl.py @@ -72,33 +72,29 @@ class FinanceIndexImpl(object): def make_search_body(param): body = dict() search_keys = list(param.keys()) + if 'name' in search_keys: + body['函数名称'] = {"$regex": param['name']} - if '函数名称' in search_keys: - body['函数名称'] = {"$regex": param['函数名称']} - - if '标签' in search_keys: - body['标签'] = {"$in": param['标签']} + if 'tags' in search_keys: + body['标签'] = {"$in": param['tags']} return body def make_sort_body(param): - if param != {}: - asc_or_desc = 1 if list(param.values())[0] == "asc" else -1 - sort_column = list(param.keys())[0] - body = {sort_column: asc_or_desc} + if param == 'asc': + body = {"编辑时间": 1} else: body = {"编辑时间": -1} return body - search = kwargs['data']['search'] - sort = kwargs['data']['sort'] - page_size = kwargs['data']['page_size'] - page_no = kwargs['data']['page_no'] - search_body = make_search_body(search) + data = kwargs['data'] + sort = data['sort'] + page_size = int(data['page_size']) + page_no = int(data['page_no']) + search_body = make_search_body(data) sort_body = make_sort_body(sort) page_size = 10 if page_size > 10 else page_size - page_no = int(page_no) total = DB_TEST.find_all_data_with_count( '模型数据', diff --git a/Modules/Functions/FinIndex/FinIndexRoutes.py b/Modules/Functions/FinIndex/FinIndexRoutes.py index 8b03f2c..8b15316 100644 --- a/Modules/Functions/FinIndex/FinIndexRoutes.py +++ b/Modules/Functions/FinIndex/FinIndexRoutes.py @@ -39,7 +39,7 @@ def check_calculate_func_route(): def search_indicators_func_route(): """查询指标计算函数""" try: - RouteParamsCheck(request.json, ["search", "sort", "page_no", "page_size"]).required() + RouteParamsCheck(req=request.json, params=["sort", "page_no", "page_size"]).required() data = request.json impl = FinanceIndexImpl() result = impl.search_calculate_func(data=data)