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

This commit is contained in:
BryantHe 2023-09-20 11:59:51 +08:00
parent 53f0df91d7
commit 5bc9e25c7a
2 changed files with 38 additions and 8 deletions

View File

@ -3,7 +3,8 @@ from flask import session
from app import rpc
from app.api.v1.exception.interaction import AddInteractionError
from app.api.v1.schema.interaction import InteractionIn, InteractionTodayIn, InteractionTodayOut
from app.api.v1.schema.interaction import (InteractionIn, InteractionBriefIn, InteractionListIn,
InteractionBriefOut, InteractionListOut)
from app.util.auth import login_required
@ -29,12 +30,25 @@ def add_interaction(json_data):
@interaction.get('/brief')
@interaction.doc(summary='查询食物记录列表', description='查询食物记录列表')
@interaction.input(InteractionTodayIn, location='query')
@interaction.output(InteractionTodayOut)
@interaction.doc(summary='查询互动简要数据', description='查询互动简要数据')
@interaction.input(InteractionBriefIn, location='query')
@interaction.output(InteractionBriefOut)
@login_required
def get_interaction_today_brief(query_data):
def get_interaction_brief(query_data):
current_date = query_data.get('current_date', None)
results = rpc.interaction.get_interaction_brief(session['user_id'],
current_date=current_date)
return results
@interaction.get('/list')
@interaction.doc(summary='查询互动列表数据', description='查询互动列表数据')
@interaction.input(InteractionListIn, location='query')
@interaction.output(InteractionListOut)
@login_required
def get_interaction_list(query_data):
current_date = query_data.get('current_date', None)
results = rpc.interaction.get_interaction_list(session['user_id'],
category=query_data['category'],
current_date=current_date)
return results

View File

@ -9,11 +9,27 @@ class InteractionIn(Schema):
comment = fields.String(allow_none=True)
class InteractionTodayIn(Schema):
class InteractionBriefIn(Schema):
current_date = fields.String()
class InteractionTodayOut(Schema):
class InteractionListIn(Schema):
current_date = fields.String()
category = fields.Integer(required=True)
class InteractionBriefOut(Schema):
fire_count = fields.Integer()
heart_count = fields.Integer()
comment_count = fields.Integer()
comment_count = fields.Integer()
class InteractionOut(Schema):
nickname = fields.String()
avatar_url = fields.String()
comment = fields.String()
create_time = fields.String()
class InteractionListOut(Schema):
interactions = fields.List(fields.Nested(InteractionOut))