From 5ddf94aa8270573d146e3bf8ab4e4c5291b8b212 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Sat, 12 Aug 2023 22:22:22 +0800 Subject: [PATCH] feat: add api of body record 11 --- app/api/v1/record.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/api/v1/record.py b/app/api/v1/record.py index 9edabd6..c783d38 100644 --- a/app/api/v1/record.py +++ b/app/api/v1/record.py @@ -10,23 +10,25 @@ record = APIBlueprint('record', __name__) @record.post('/') -@record.input(BodyRecordIn) @record.doc(summary='添加身体记录', description='添加身体记录') +@record.input(BodyRecordIn, location='json') @login_required def add_record(json_data): try: - rpc.body_record.add(user_id=session['user_id'], - height=json_data['height'], - weight=json_data['weight'], - bmi=json_data['bmi']) + rpc.body_record.add(**{ + 'user_id': session['user_id'], + 'height': json_data['height'], + 'weight': json_data['weight'], + 'bmi': json_data['bmi'] + }) except Exception as e: raise AddBodyRecordError(extra_data={'error_docs': str(e)}) return {'msg': 'add body record success'} @record.get('/') -@record.output(BodyRecordOut) @record.doc(summary='查询单条身体记录', description='查询单条身体记录') +@record.output(BodyRecordOut) @login_required def get_record(record_id): try: @@ -37,8 +39,8 @@ def get_record(record_id): @record.get('/list') -@record.output(BodyRecordsOut) @record.doc(summary='查询身体记录列表', description='查询身体记录列表') +@record.output(BodyRecordsOut) @login_required def get_records(): try: