fix: 修改用户信息接口的返回值
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
330084ea4a
commit
d039cc69e1
|
@ -1,5 +1,5 @@
|
|||
from apiflask import Schema
|
||||
from apiflask.fields import String, Float
|
||||
from apiflask.fields import String, Float, URL
|
||||
|
||||
|
||||
class UserInfoIn(Schema):
|
||||
|
@ -10,4 +10,5 @@ class UserInfoIn(Schema):
|
|||
class UserInfoOut(Schema):
|
||||
nickname = String()
|
||||
avatar_id = String()
|
||||
avatar_url = URL()
|
||||
height = Float(allow_nan=True)
|
|
@ -2,6 +2,7 @@ from apiflask import APIBlueprint
|
|||
from flask import session
|
||||
|
||||
from app import rpc
|
||||
from app.api.v1.exception.api import ImageNotFound
|
||||
from app.api.v1.exception.user import UserInfoNotFound, UserInfoError
|
||||
from app.api.v1.schema.user import UserInfoIn, UserInfoOut
|
||||
from app.util.auth import login_required
|
||||
|
@ -40,16 +41,23 @@ def get_user_info():
|
|||
except Exception as e:
|
||||
raise UserInfoNotFound(extra_data={'error_docs': str(e)})
|
||||
|
||||
try:
|
||||
presign_url = rpc.storage.get_presign_url(user_dict['avatar_id'],
|
||||
'bodyrecord',
|
||||
bucket='bodyrecord')
|
||||
user_dict['avatar_url'] = presign_url
|
||||
except Exception as e:
|
||||
raise ImageNotFound(extra_data={'error_docs': str(e)})
|
||||
|
||||
try:
|
||||
body_info_dict = rpc.body_record.get_body_info(session['user_id'])
|
||||
except Exception as e:
|
||||
raise UserInfoNotFound(extra_data={'error_docs': str(e)})
|
||||
|
||||
if user_dict:
|
||||
result.update(user_dict)
|
||||
if body_info_dict:
|
||||
result['height'] = body_info_dict.get('height', None)
|
||||
else:
|
||||
result['height'] = None
|
||||
result.update(user_dict)
|
||||
if body_info_dict:
|
||||
result['height'] = body_info_dict.get('height', None)
|
||||
else:
|
||||
result['height'] = None
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue