From 92053755c9c68838136c1aa802b831bdbc43ab29 Mon Sep 17 00:00:00 2001 From: P3ngSaM <61768364+P3ngSaM@users.noreply.github.com> Date: Tue, 28 Jun 2022 10:17:51 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=AE=80=E5=8C=96=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/Functions/FinIndex/FinIndexImpl.py | 26 +++++++++----------- Modules/Functions/FinIndex/FinIndexRoutes.py | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) 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)