Ver Fonte

Update user_manager: more functions for local dev mode

StrayWarrior há 1 mês atrás
pai
commit
2073150f61
1 ficheiros alterados com 17 adições e 9 exclusões
  1. 17 9
      pqai_agent/user_manager.py

+ 17 - 9
pqai_agent/user_manager.py

@@ -124,13 +124,16 @@ class LocalUserManager(UserManager):
         return user_ids
 
     def get_staff_profile(self, staff_id) -> Dict:
-        # for test only
-        return {
-            'agent_name': '小芳',
-            'agent_gender': '女',
-            'agent_age': 30,
-            'agent_region': '北京'
-        }
+        try:
+            with open(f"user_profiles/{staff_id}.json", "r", encoding="utf-8") as f:
+                profile = json.load(f)
+            entry_added = False
+            if entry_added:
+                self.save_user_profile(staff_id, profile)
+            return profile
+        except Exception as e:
+            logger.error("staff profile not found: {}".format(e))
+            return {}
 
     def list_users(self, **kwargs) -> List[Dict]:
         pass
@@ -221,15 +224,20 @@ class LocalUserRelationManager(UserRelationManager):
 
     def list_staffs(self):
         return [
-            {"third_party_user_id": 0, "name": "x", "wxid": "x", "agent_name": "小芳"}
+            {"third_party_user_id": '1688855931724582', "name": "", "wxid": "ShengHuoLeQu", "agent_name": "小芳"}
         ]
 
     def list_users(self, staff_id: str, page: int = 1, page_size: int = 100):
         return []
 
     def list_staff_users(self, staff_id: str = None, tag_id: int = None):
+        user_ids = ['7881299453089278', '7881299453132630', '7881299454186909', '7881299455103430', '7881299455173476',
+                    '7881299456216398', '7881299457990953', '7881299461167644', '7881299463002136', '7881299464081604',
+                    '7881299465121735', '7881299465998082', '7881299466221881', '7881299467152300', '7881299470051791',
+                    '7881299470112816', '7881299471149567', '7881299471168030', '7881299471277650', '7881299473321703']
         return [
-            {"staff_id": "1688854492669990", "user_id": "7881299670930896"}
+            {"staff_id": "1688855931724582", "user_id": "7881299670930896"},
+            *[{"staff_id": "1688855931724582", "user_id": user_id} for user_id in user_ids]
         ]
 
     def get_user_tags(self, user_id: str):