feat: add api of today brief
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7f21fac864
commit
4214e7b797
@ -4,3 +4,8 @@ from apiflask import HTTPError
|
|||||||
class AddInteractionError(HTTPError):
|
class AddInteractionError(HTTPError):
|
||||||
status_code = 500
|
status_code = 500
|
||||||
message = 'add interaction failed.'
|
message = 'add interaction failed.'
|
||||||
|
|
||||||
|
|
||||||
|
class InteractionTodayBriefNotFound(HTTPError):
|
||||||
|
status_code = 404
|
||||||
|
message = '找不到用户对应的食物记录'
|
@ -3,7 +3,7 @@ from flask import session
|
|||||||
|
|
||||||
from app import rpc
|
from app import rpc
|
||||||
from app.api.v1.exception.interaction import AddInteractionError
|
from app.api.v1.exception.interaction import AddInteractionError
|
||||||
from app.api.v1.schema.interaction import InteractionIn
|
from app.api.v1.schema.interaction import InteractionIn, InteractionTodayIn, InteractionTodayOut
|
||||||
|
|
||||||
from app.util.auth import login_required
|
from app.util.auth import login_required
|
||||||
|
|
||||||
@ -26,3 +26,15 @@ def add_interaction(json_data):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AddInteractionError(extra_data={'error_docs': str(e)})
|
raise AddInteractionError(extra_data={'error_docs': str(e)})
|
||||||
return {'msg': 'add interaction successfully'}
|
return {'msg': 'add interaction successfully'}
|
||||||
|
|
||||||
|
|
||||||
|
@interaction.get('/today/brief')
|
||||||
|
@interaction.doc(summary='查询食物记录列表', description='查询食物记录列表')
|
||||||
|
@interaction.input(InteractionTodayIn, location='query')
|
||||||
|
@interaction.output(InteractionTodayOut)
|
||||||
|
@login_required
|
||||||
|
def get_interaction_today_brief(query_data):
|
||||||
|
current_date = query_data.get('current_date', None)
|
||||||
|
results = rpc.interaction.get_today_brief(session['user_id'],
|
||||||
|
current_date=current_date)
|
||||||
|
return results
|
@ -7,3 +7,13 @@ class InteractionIn(Schema):
|
|||||||
receiver_id = fields.String()
|
receiver_id = fields.String()
|
||||||
related_party_id = fields.String(allow_none=True)
|
related_party_id = fields.String(allow_none=True)
|
||||||
comment = fields.String(allow_none=True)
|
comment = fields.String(allow_none=True)
|
||||||
|
|
||||||
|
|
||||||
|
class InteractionTodayIn(Schema):
|
||||||
|
current_date = fields.String()
|
||||||
|
|
||||||
|
|
||||||
|
class InteractionTodayOut(Schema):
|
||||||
|
fire_count = fields.Integer()
|
||||||
|
heart_count = fields.Integer()
|
||||||
|
comment_count = fields.Integer()
|
Loading…
Reference in New Issue
Block a user