diff --git a/app/api/v1/schema/user.py b/app/api/v1/schema/user.py index 3b86885..ad0770d 100644 --- a/app/api/v1/schema/user.py +++ b/app/api/v1/schema/user.py @@ -1,14 +1,17 @@ from apiflask import Schema -from apiflask.fields import String, Float, URL +from apiflask.fields import String, Float, URL, Boolean class UserInfoIn(Schema): nickname = String() height = Float() + is_hidden_weight = Boolean() class UserInfoOut(Schema): + user_id = String(attribute='_id') nickname = String() avatar_id = String() avatar_url = URL() - height = Float(allow_nan=True) \ No newline at end of file + height = Float(allow_nan=True) + is_hidden_weight = Boolean() \ No newline at end of file diff --git a/app/api/v1/user.py b/app/api/v1/user.py index 5dc2210..232dddf 100644 --- a/app/api/v1/user.py +++ b/app/api/v1/user.py @@ -23,7 +23,8 @@ def set_user_info(json_data): try: 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),) except Exception as e: raise UserInfoError(extra_data={'error_docs': str(e)}) @@ -57,7 +58,12 @@ def get_user_info(): result.update(user_dict) if body_info_dict: result['height'] = body_info_dict.get('height', None) + if body_info_dict.get('is_hidden_weight', None): + result['is_hidden_weight'] = True + else: + result['is_hidden_weight'] = False else: result['height'] = None + result['is_hidden_weight'] = False return result