feat: add api of get_record_count
continuous-integration/drone/push Build is passing Details

This commit is contained in:
BryantHe 2023-09-20 14:22:39 +08:00
parent 001722e195
commit f9680363f4
2 changed files with 15 additions and 1 deletions

View File

@ -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_id>')
@record.doc(summary='查询单条身体记录', description='查询单条身体记录')
@record.output(BodyRecordOut)

View File

@ -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()