def show_wx_xnr(submitter): wx_xnr_mappings() #创建wx_xnr表 query_body = { 'query': { 'term': {'submitter': submitter} }, 'size': MAX_VALUE } res = [] res = es_xnr.search(index=wx_xnr_index_name, doc_type=wx_xnr_index_type, body=query_body)['hits']['hits'] wx_xnr_list = [] for item in res: data = item['_source'] wxbot_id = data['xnr_user_no'] xnr_data = { 'wx_id': data['wx_id'], 'wxbot_id': wxbot_id, 'wxbot_port': data.get('wxbot_port'), 'wx_groups_nickname': data.get('wx_groups_nickname'), 'wx_groups_num': data.get('wx_groups_num'), 'create_ts': data.get('create_ts'), 'login_status': check_status(wxbot_id), } wx_xnr_list.append(xnr_data) return wx_xnr_list
def show_wx_xnr_listening_groups(wxbot_id): wx_xnr_mappings() #创建wx_xnr表 xnr_puid = load_wxxnr_redis_data(wxbot_id=wxbot_id, items=['puid'])['puid'] query_body = { 'query':{ 'bool':{ 'must':[ {'term':{'puid':xnr_puid}} ] } } } res = [] res = es_xnr.search(index=wx_xnr_index_name, doc_type=wx_xnr_index_type, body=query_body)['hits']['hits'] wx_xnr_listening_groups = [] for item in res: data = item['_source'] wxbot_id = data['xnr_user_no'] xnr_data = { 'wxbot_id': wxbot_id, 'wx_groups_nickname': data.get('wx_groups_nickname'), 'wx_groups_id': data.get('wx_groups_puid') } wx_xnr_listening_groups.append(xnr_data) if len(wx_xnr_listening_groups) == 1: return wx_xnr_listening_groups[0] return 0
def check_wx_xnr(wx_id): wx_xnr_mappings() #创建wx_xnr表 query_body_wx_exist={'query':{'term':{'wx_id':wx_id}}} search_result = es_xnr.search(index=wx_xnr_index_name,doc_type=wx_xnr_index_type, body=query_body_wx_exist)['hits']['hits'] if search_result: wxxnr_data = search_result[0]['_source'] wxbot_id = wxxnr_data['xnr_user_no'] wxbot_port = wxxnr_data['wxbot_port'] wx_groups_puid = wxxnr_data.get('wx_groups_puid') if wx_groups_puid: groups_list = ','.join(wx_groups_puid) else: groups_list = '' data = {'wxbot_id':wxbot_id, 'wxbot_port':wxbot_port, 'groups_list':groups_list} return data return False