diff --git a/services/plan_service.py b/services/plan_service.py index 1028a7d8ecdf112897ec89ff443c7704ffedccf4..a73474fd72ef7902f73a87f7bafd5f15bd5b30b9 100644 --- a/services/plan_service.py +++ b/services/plan_service.py @@ -20,10 +20,11 @@ ERROR_NO_AUTO_TASK = '没有需要执行的任务' PLAN_KEY = 'plan_dict' -async def get_plans(content=None, page_num=1, page_size=10): +async def get_plans(content=None): + fields = [Plan.title, Plan.id, Plan.status] if not content: - return await Plan.query_page(page_num=page_num, page_size=page_size) - return await Plan.query_page(page_num, page_size, match={'title': 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)) async def create_plan(data, owner): diff --git a/views/plan_view.py b/views/plan_view.py index 45efae43b7517d160e004ec9ce6e461af593a3f1..b3ec6c66dc6cf6790111dafb8020c393b85d7827 100644 --- a/views/plan_view.py +++ b/views/plan_view.py @@ -11,11 +11,9 @@ bp = Blueprint('plan', url_prefix='api/plan') @bp.route('') @login_auth async def get_plan_list(request, user_infos): - page_num = int(request.args.get('page_num')) if request.args.get('page_num') else 1 - page_size = int(request.args.get('page_size')) if request.args.get('page_size') else 30 content = request.args.get('content') if request.args.get('content') else None - result = await get_plans(content, page_num, page_size) - return rsp(paginate=result) + result = await get_plans(content) + return rsp(data=result) @bp.post('/create')