From e95544c1f3b0d64f9fff59c74d6752e0c27e0fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AD=A6=E5=B3=B0?= Date: Fri, 22 Jul 2022 15:42:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=96=B9=E6=A1=88=E7=9A=84=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/plan_service.py | 11 +++++++---- views/plan_view.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/services/plan_service.py b/services/plan_service.py index a73474f..606b7c0 100644 --- a/services/plan_service.py +++ b/services/plan_service.py @@ -20,11 +20,14 @@ ERROR_NO_AUTO_TASK = '没有需要执行的任务' PLAN_KEY = 'plan_dict' -async def get_plans(content=None): +async def get_plans(content=None, status=None): fields = [Plan.title, Plan.id, Plan.status] - if not content: - return await Plan.query_obj_all_by_fields(fields, Plan.id) - return await Plan.query_obj_all_by_fields(fields, Plan.id, Plan.title.contains(content)) + conditions = list() + if content: + conditions.append(Plan.title.contains(content)) + if status: + conditions.append(Plan.status == status) + return await Plan.query_obj_all_by_fields(fields, Plan.id, *conditions) async def create_plan(data, owner): diff --git a/views/plan_view.py b/views/plan_view.py index b3ec6c6..4988348 100644 --- a/views/plan_view.py +++ b/views/plan_view.py @@ -11,8 +11,9 @@ bp = Blueprint('plan', url_prefix='api/plan') @bp.route('') @login_auth async def get_plan_list(request, user_infos): + status = request.args.get('status') if request.args.get('status') else None content = request.args.get('content') if request.args.get('content') else None - result = await get_plans(content) + result = await get_plans(content, status) return rsp(data=result) -- Gitee