feat: add bodyinfo field age
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5a10303133
commit
721a5f1aa8
|
@ -1,10 +1,11 @@
|
|||
from apiflask import Schema
|
||||
from apiflask.fields import String, Float, URL, Boolean
|
||||
from apiflask.fields import String, Float, URL, Boolean, Integer
|
||||
|
||||
|
||||
class UserInfoIn(Schema):
|
||||
nickname = String()
|
||||
gender = String()
|
||||
age = Integer()
|
||||
height = Float()
|
||||
is_hidden_weight = Boolean()
|
||||
|
||||
|
@ -17,6 +18,7 @@ class UserInfoOut(Schema):
|
|||
user_id = String(attribute='_id')
|
||||
nickname = String()
|
||||
gender = String()
|
||||
age = Integer()
|
||||
avatar_id = String()
|
||||
avatar_url = URL()
|
||||
height = Float(allow_nan=True)
|
||||
|
|
|
@ -25,7 +25,8 @@ def set_user_info(json_data):
|
|||
rpc.body_record.set_body_info(session['user_id'],
|
||||
height=json_data.get('height', None),
|
||||
is_hidden_weight=json_data.get('is_hidden_weight', None),
|
||||
gender=json_data.get('gender', None))
|
||||
gender=json_data.get('gender', None),
|
||||
age=json_data.get('age', None))
|
||||
except Exception as e:
|
||||
raise UserInfoError(extra_data={'error_docs': str(e)})
|
||||
|
||||
|
@ -33,7 +34,7 @@ def set_user_info(json_data):
|
|||
|
||||
|
||||
@user.get('/info')
|
||||
@user.doc(summary='查询用户信息', description='查询用户信息。注:gender 1 代表男性,2 代表女性')
|
||||
@user.doc(summary='查询用户信息', description='查询用户信息。注:gender 类型:str, 1 代表男性,2 代表女性')
|
||||
@user.input(UserIdIn, location='query')
|
||||
@user.output(UserInfoOut)
|
||||
@login_required
|
||||
|
@ -62,6 +63,7 @@ def get_user_info(query_data):
|
|||
if body_info_dict:
|
||||
result['height'] = body_info_dict.get('height', None)
|
||||
result['gender'] = body_info_dict.get('gender', None)
|
||||
result['age'] = body_info_dict.get('age', None)
|
||||
if body_info_dict.get('is_hidden_weight', None):
|
||||
result['is_hidden_weight'] = True
|
||||
else:
|
||||
|
@ -70,5 +72,6 @@ def get_user_info(query_data):
|
|||
result['height'] = None
|
||||
result['is_hidden_weight'] = False
|
||||
result['gender'] = None
|
||||
result['age'] = None
|
||||
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue