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

This commit is contained in:
BryantHe 2023-08-26 11:05:45 +08:00
parent 63e6311d17
commit b86ef1376e
2 changed files with 17 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from flask import session
from app import rpc from app import rpc
from app.api.v1.exception.record import AddBodyRecordError, BodyRecordNotFound, BodyRecordChartError from app.api.v1.exception.record import AddBodyRecordError, BodyRecordNotFound, BodyRecordChartError
from app.api.v1.schema.record import BodyRecordIn, BodyRecordOut, BodyRecordsOut, BodyRecordsIn, BodyRecordChartIn, \ from app.api.v1.schema.record import BodyRecordIn, BodyRecordOut, BodyRecordsOut, BodyRecordsIn, BodyRecordChartIn, \
BodyRecordChartOut BodyRecordChartOut, BodyRecordIdIn
from app.util.auth import login_required from app.util.auth import login_required
record = APIBlueprint('record', __name__) record = APIBlueprint('record', __name__)
@ -39,6 +39,18 @@ def get_record(record_id):
return result return result
@record.delete('/<record_id>')
@record.doc(summary='删除单条身体记录', description='删除单条身体记录')
@record.input(BodyRecordIdIn, location='json')
@login_required
def delete_record(json_data):
try:
rpc.body_record.delete_one(json_data['record_id'])
except Exception as e:
raise BodyRecordNotFound(extra_data={'error_docs': str(e)})
return {'msg': ' delete body record success'}
@record.get('/list') @record.get('/list')
@record.doc(summary='查询身体记录列表', description='查询身体记录列表') @record.doc(summary='查询身体记录列表', description='查询身体记录列表')
@record.input(BodyRecordsIn, location='query') @record.input(BodyRecordsIn, location='query')

View File

@ -8,6 +8,10 @@ class BodyRecordIn(Schema):
bmi = fields.Float() bmi = fields.Float()
class BodyRecordIdIn(Schema):
record_id = fields.String(required=True)
class BodyRecordOut(Schema): class BodyRecordOut(Schema):
record_id = fields.String(attribute='_id') record_id = fields.String(attribute='_id')
height = fields.Float() height = fields.Float()