fix 部分api请求失败情况下,不会噶了

This commit is contained in:
xaoyaoo committed 2024-08-07 18:26:49 +08:00
1 parent 5d18f4193c
commit a4ba8fa50d
4 files changed
+6 -5

No files matched your search

-3
View File
@@ -42,9 +42,6 @@ class DBHandler(MicroHandler, MediaHandler, OpenIMContactHandler, PublicMsgHandl
if self.Micro_exist: # 添加索引
self.Micro_add_index()
# print(self.MSG_exist, self.Micro_exist, self.Media_exist, self.OpenIMContact_exist, self.PublicMsg_exist,
# self.OpenIMMedia_exist, self.Favorite_exist)
def get_user(self, word=None, wxids=None, labels=None):
"""
获取联系人列表
+2
View File
@@ -59,6 +59,8 @@ class MicroHandler(DatabaseBase):
:param id_is_key: id_is_key: True: id作为key,False: name作为key
:return:
"""
if (self.table_exist.get("ContactLabel") is None) or (not self.table_exist.get("ContactLabel")):
return []
sql = "SELECT LabelId, LabelName FROM ContactLabel ORDER BY LabelName ASC;"
result = self.execute(sql)
if not result:
+2
View File
@@ -79,6 +79,7 @@ class DatabaseSingletonBase:
class DatabaseBase(DatabaseSingletonBase):
_class_name = "DatabaseBase"
table_exist = {}
def __init__(self, db_config):
"""
@@ -134,6 +135,7 @@ class DatabaseBase(DatabaseSingletonBase):
f"WHERE type='table' AND tbl_name in ({required_tables_str});")
existing_tables = self.execute(sql)
existing_tables = [row[0] for row in existing_tables] # 将查询结果转换为列表
self.table_exist = {table: table in existing_tables for table in required_tables}
# 检查所有必需的表是否都在现有表中
return all(table in existing_tables for table in required_tables)