Browse Source

reformat staff_profile get and save interface

luojunhui 1 month ago
parent
commit
965812249e
1 changed files with 3 additions and 5 deletions
  1. 3 5
      pqai_agent_server/api_server.py

+ 3 - 5
pqai_agent_server/api_server.py

@@ -72,16 +72,14 @@ def save_staff_profile():
     else:
         try:
             profile_info_list = json.loads(staff_profile)
-            profile_dict = {}
-            for profile_info in profile_info_list:
-                field_name = profile_info['field_name']
-                profile_dict[field_name] = profile_info['field_value']
-
+            profile_dict = {item['field_name']: item['field_value'] for item in profile_info_list}
             affected_rows = app.staff_manager.save_staff_profile(staff_id, profile_dict)
+
             if not affected_rows:
                 return wrap_response(500, msg='save staff profile failed')
             else:
                 return wrap_response(200, msg='save staff profile success')
+
         except json.decoder.JSONDecodeError:
             return wrap_response(400, msg='profile is not a valid json')