From 3b3365fcfb67d55c68150d283834ceb61cec8892 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Wed, 20 Sep 2023 16:09:05 +0800 Subject: [PATCH] fix: adjust upload_diet_image --- app/api/v1/api.py | 10 +++++++++- app/api/v1/schema/api.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/api/v1/api.py b/app/api/v1/api.py index c3ea9ac..95c61a3 100644 --- a/app/api/v1/api.py +++ b/app/api/v1/api.py @@ -56,7 +56,15 @@ def upload_avatar_image(files_data): @login_required def upload_diet_image(files_data): f = files_data['image'] - category = files_data['category'] # 食物类别 + category_dict = { + 0: '早餐', + 1: '午餐', + 2: '晚餐', + 3: '零食', + 4: '下午茶', + 5: '夜宵', + } + category = category_dict[files_data['category']] # 食物类别 try: result = rpc.storage.upload(file_name=str(session['user_id'] + f'_{f.filename}'), file_binary=f.read(), diff --git a/app/api/v1/schema/api.py b/app/api/v1/schema/api.py index 1bf55af..afa3122 100644 --- a/app/api/v1/schema/api.py +++ b/app/api/v1/schema/api.py @@ -8,7 +8,7 @@ class ImageIn(Schema): class DietImageIn(Schema): image = File() - category = String() + category = Integer() class ImagePreSignUrlIn(Schema):