|
@@ -252,11 +252,13 @@ class MySQLUserRelationManager(UserRelationManager):
|
|
|
def list_users(self, staff_id: str, page: int = 1, page_size: int = 100):
|
|
|
return []
|
|
|
|
|
|
- def list_staff_users(self):
|
|
|
+ def list_staff_users(self, staff_id: str = None, tag_id: int = None):
|
|
|
# FIXME(zhoutian)
|
|
|
# 测试期间逻辑,只取一个账号
|
|
|
- sql = (f"SELECT third_party_user_id, wxid FROM {self.agent_staff_table} WHERE status = 1"
|
|
|
- f" AND third_party_user_id in ('1688854492669990', '1688855931724582')")
|
|
|
+ sql = f"SELECT third_party_user_id, wxid FROM {self.agent_staff_table} WHERE status = 1"
|
|
|
+ # f" AND third_party_user_id in ('1688854492669990', '1688855931724582')")
|
|
|
+ if staff_id:
|
|
|
+ sql += f" AND third_party_user_id = '{staff_id}'"
|
|
|
agent_staff_data = self.agent_db.select(sql, pymysql.cursors.DictCursor)
|
|
|
if not agent_staff_data:
|
|
|
return []
|
|
@@ -276,11 +278,9 @@ class MySQLUserRelationManager(UserRelationManager):
|
|
|
continue
|
|
|
user_ids = tuple(user['user_id'] for user in user_data)
|
|
|
# FIXME(zhoutian): 测试期间临时逻辑
|
|
|
- if True:
|
|
|
- sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
|
|
|
- else:
|
|
|
- sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null" \
|
|
|
- f" AND id in (SELECT distinct user_id FROM we_com_user_with_tag WHERE tag_id = 15 and is_delete = 0)"
|
|
|
+ sql = f"SELECT union_id FROM {self.user_table} WHERE id IN {str(user_ids)} AND union_id is not null"
|
|
|
+ if tag_id:
|
|
|
+ sql += f" AND id in (SELECT distinct user_id FROM we_com_user_with_tag WHERE tag_id = {tag_id} and is_delete = 0)"
|
|
|
user_data = self.wecom_db.select(sql, pymysql.cursors.DictCursor)
|
|
|
if not user_data:
|
|
|
logger.warning(f"staff[{wxid}] users not found in wecom database")
|