pzx-web-api/app/api/v1/interaction.py

28 lines
1005 B
Python
Raw Normal View History

2023-09-18 16:29:24 +08:00
from apiflask import APIBlueprint
from flask import session
from app import rpc
from app.api.v1.exception.interaction import AddInteractionError
from app.api.v1.schema.interaction import InteractionIn
from app.util.auth import login_required
interaction = APIBlueprint('interaction', __name__)
@interaction.post('/')
2023-09-18 16:52:26 +08:00
@interaction.doc(summary='添加互动记录', description='添加互动记录category 类型int1:点赞2:加油3:评论')
2023-09-18 16:29:24 +08:00
@interaction.input(InteractionIn, location='json')
@login_required
def add_interaction(json_data):
try:
rpc.interaction.add(**{
'sender': session['user_id'],
'receiver': json_data['receiver_id'],
'category': json_data['category'],
'related_party': json_data.get('related_party_id'),
'comment': json_data.get('comment')
})
except Exception as e:
raise AddInteractionError(extra_data={'error_docs': str(e)})
return {'msg': 'add interaction successfully'}