feat: add gender field
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
c34f1a4fed
commit
5a10303133
|
@ -4,6 +4,7 @@ from apiflask.fields import String, Float, URL, Boolean
|
||||||
|
|
||||||
class UserInfoIn(Schema):
|
class UserInfoIn(Schema):
|
||||||
nickname = String()
|
nickname = String()
|
||||||
|
gender = String()
|
||||||
height = Float()
|
height = Float()
|
||||||
is_hidden_weight = Boolean()
|
is_hidden_weight = Boolean()
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ class UserIdIn(Schema):
|
||||||
class UserInfoOut(Schema):
|
class UserInfoOut(Schema):
|
||||||
user_id = String(attribute='_id')
|
user_id = String(attribute='_id')
|
||||||
nickname = String()
|
nickname = String()
|
||||||
|
gender = String()
|
||||||
avatar_id = String()
|
avatar_id = String()
|
||||||
avatar_url = URL()
|
avatar_url = URL()
|
||||||
height = Float(allow_nan=True)
|
height = Float(allow_nan=True)
|
||||||
|
|
|
@ -11,7 +11,7 @@ user = APIBlueprint('user', __name__)
|
||||||
|
|
||||||
|
|
||||||
@user.post('/info')
|
@user.post('/info')
|
||||||
@user.doc(summary='设置用户信息', description='设置用户信息')
|
@user.doc(summary='设置用户信息', description='设置用户信息。注:gender 1 代表男性,2 代表女性')
|
||||||
@user.input(UserInfoIn, location='json')
|
@user.input(UserInfoIn, location='json')
|
||||||
@login_required
|
@login_required
|
||||||
def set_user_info(json_data):
|
def set_user_info(json_data):
|
||||||
|
@ -24,7 +24,8 @@ def set_user_info(json_data):
|
||||||
try:
|
try:
|
||||||
rpc.body_record.set_body_info(session['user_id'],
|
rpc.body_record.set_body_info(session['user_id'],
|
||||||
height=json_data.get('height', None),
|
height=json_data.get('height', None),
|
||||||
is_hidden_weight=json_data.get('is_hidden_weight', None),)
|
is_hidden_weight=json_data.get('is_hidden_weight', None),
|
||||||
|
gender=json_data.get('gender', None))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise UserInfoError(extra_data={'error_docs': str(e)})
|
raise UserInfoError(extra_data={'error_docs': str(e)})
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ def set_user_info(json_data):
|
||||||
|
|
||||||
|
|
||||||
@user.get('/info')
|
@user.get('/info')
|
||||||
@user.doc(summary='查询用户信息', description='查询用户信息')
|
@user.doc(summary='查询用户信息', description='查询用户信息。注:gender 1 代表男性,2 代表女性')
|
||||||
@user.input(UserIdIn, location='query')
|
@user.input(UserIdIn, location='query')
|
||||||
@user.output(UserInfoOut)
|
@user.output(UserInfoOut)
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -60,6 +61,7 @@ def get_user_info(query_data):
|
||||||
result.update(user_dict)
|
result.update(user_dict)
|
||||||
if body_info_dict:
|
if body_info_dict:
|
||||||
result['height'] = body_info_dict.get('height', None)
|
result['height'] = body_info_dict.get('height', None)
|
||||||
|
result['gender'] = body_info_dict.get('gender', None)
|
||||||
if body_info_dict.get('is_hidden_weight', None):
|
if body_info_dict.get('is_hidden_weight', None):
|
||||||
result['is_hidden_weight'] = True
|
result['is_hidden_weight'] = True
|
||||||
else:
|
else:
|
||||||
|
@ -67,5 +69,6 @@ def get_user_info(query_data):
|
||||||
else:
|
else:
|
||||||
result['height'] = None
|
result['height'] = None
|
||||||
result['is_hidden_weight'] = False
|
result['is_hidden_weight'] = False
|
||||||
|
result['gender'] = None
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue