diff --git a/app/api/v1/record.py b/app/api/v1/record.py index 3b7f771..b519010 100644 --- a/app/api/v1/record.py +++ b/app/api/v1/record.py @@ -4,7 +4,7 @@ from flask import session from app import rpc from app.api.v1.exception.record import AddBodyRecordError, BodyRecordNotFound, BodyRecordChartError from app.api.v1.schema.record import BodyRecordIn, BodyRecordOut, BodyRecordsOut, BodyRecordsIn, BodyRecordChartIn, \ - BodyRecordChartOut + BodyRecordChartOut, BodyRecordCountOut from app.util.auth import login_required record = APIBlueprint('record', __name__) @@ -27,6 +27,16 @@ def add_record(json_data): return {'msg': 'add body record success'} +@record.get('/count') +@record.doc(summary='查询身体记录数量', description='查询身体记录数量') +@record.output(BodyRecordCountOut) +@login_required +def get_record_count(): + result = rpc.body_record.get_record_count(session['user_id']) + count = result if result else 0 + return {'count': count} + + @record.get('/') @record.doc(summary='查询单条身体记录', description='查询单条身体记录') @record.output(BodyRecordOut) diff --git a/app/api/v1/schema/record.py b/app/api/v1/schema/record.py index e4545bc..dc70481 100644 --- a/app/api/v1/schema/record.py +++ b/app/api/v1/schema/record.py @@ -12,6 +12,10 @@ class BodyRecordIdIn(Schema): record_id = fields.String(required=True) +class BodyRecordCountOut(Schema): + count = fields.Integer() + + class BodyRecordOut(Schema): record_id = fields.String(attribute='_id') height = fields.Float()