From f9680363f4ac08b4cbd7cb0e10a5d4cdb8af1143 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Wed, 20 Sep 2023 14:22:39 +0800 Subject: [PATCH] feat: add api of get_record_count --- app/api/v1/record.py | 12 +++++++++++- app/api/v1/schema/record.py | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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()