添加 刷新通讯录功能,用于解决冗余数据问题。
This commit is contained in:
@@ -663,3 +663,66 @@ class ContactsDBOperator(BaseDBOperator):
|
||||
except Exception as e:
|
||||
self.LOG.error(f"删除群聊{chatroom_id}信息失败: {e}")
|
||||
return False
|
||||
|
||||
#新增获取群列表接口
|
||||
def get_chatroom_list(self) -> List[dict]:
|
||||
"""获取群列表"""
|
||||
try:
|
||||
sql = "SELECT * FROM t_chatrooms"
|
||||
results = self.execute_query(sql)
|
||||
for result in results:
|
||||
if result.get('member_list'):
|
||||
result['member_list'] = json.loads(result['member_list'])
|
||||
return results
|
||||
except Exception as e:
|
||||
self.LOG.error(f"获取群列表失败: {e}")
|
||||
return []
|
||||
|
||||
#新增获取群成员列表接口
|
||||
def get_chatroom_member_list(self, chatroom_id: str) -> List[dict]:
|
||||
"""获取群成员列表"""
|
||||
try:
|
||||
sql = "SELECT * FROM t_chatroom_member WHERE chatroom_id = %s"
|
||||
results = self.execute_query(sql, (chatroom_id,))
|
||||
return results
|
||||
except Exception as e:
|
||||
self.LOG.error(f"获取群{chatroom_id}成员列表失败: {e}")
|
||||
return []
|
||||
|
||||
#新增获取群成员信息接口
|
||||
def get_chatroom_member_info(self, chatroom_id: str, wxid: str) -> Optional[dict]:
|
||||
"""获取群成员信息"""
|
||||
try:
|
||||
sql = "SELECT * FROM t_chatroom_member WHERE chatroom_id = %s AND wxid = %s LIMIT 1"
|
||||
result = self.execute_query(sql, (chatroom_id, wxid), fetch_one=True)
|
||||
return result
|
||||
except Exception as e:
|
||||
self.LOG.error(f"获取群{chatroom_id}成员{wxid}信息失败: {e}")
|
||||
return None
|
||||
|
||||
#新增群信息删除功能
|
||||
def delete_chatroom_member_info(self, chatroom_id: str, wxid: str) -> bool:
|
||||
"""删除群成员信息"""
|
||||
try:
|
||||
sql = "DELETE FROM t_chatroom_member WHERE chatroom_id = %s AND wxid = %s"
|
||||
self.execute_update(sql, (chatroom_id, wxid))
|
||||
self.LOG.info(f"成功删除群{chatroom_id}成员{wxid}信息")
|
||||
sql = "DELETE FROM t_chatrooms WHERE chatroom_id = %s"
|
||||
self.execute_update(sql, (chatroom_id,))
|
||||
self.LOG.info(f"成功删除群聊 {chatroom_id} 信息")
|
||||
return True
|
||||
except Exception as e:
|
||||
self.LOG.error(f"删除群{chatroom_id}信息失败: {e}")
|
||||
return False
|
||||
|
||||
#新增删除所有联系人功能
|
||||
def delete_all_contacts(self) -> bool:
|
||||
"""删除所有联系人信息"""
|
||||
try:
|
||||
sql = "DELETE FROM t_wechat_contacts"
|
||||
self.execute_update(sql)
|
||||
self.LOG.info(f"成功删除所有联系人信息")
|
||||
return True
|
||||
except Exception as e:
|
||||
self.LOG.error(f"删除所有联系人信息失败: {e}")
|
||||
return False
|
||||
Reference in New Issue
Block a user