示例#1
0
def get_dialog_by_user_id(user_id):
    from get_db_data import get_data
    dialog = ''
    for row in get_data(
            query=
            f"select chat_id from crm.v_bot_users a where chat_type = 1 and user_id={user_id}"
    )['rows']:
        dialog = row['CHAT_ID']
    return dialog
示例#2
0
def get_email_by_user_id(user_id):
    from get_db_data import get_data
    f_login = ''
    for row in get_data(
            query=
            f"select lower(email) email from crm.v_bot_users a where chat_type = 1 and user_id={user_id}"
    )['rows']:
        f_login = row['EMAIL']
    return f_login
示例#3
0
def get_root_id_by_user_id(user_id):
    from get_db_data import get_data
    root_id, root_id1 = -404, -404
    email = ""
    for row in get_data(
            query=
            f"select lower(email) email, nvl(root_id,-404) root_id from crm.v_bot_users a where chat_type = 1 and user_id={user_id}"
    )['rows']:
        email = row['EMAIL']
        root_id1 = int(row['ROOT_ID'])
    if email not in ('', 'None'):
        for row in get_data(
                query=
                f"select crm.f_bot_get_root_id('{email}') root_id from dual"
        )['rows']:
            root_id = row['ROOT_ID']
    if int(root_id) == -404:
        return root_id1
    else:
        return root_id
示例#4
0
def get_short_login_by_user_id(user_id):
    from get_db_data import get_data
    import ldap
    f_login = '******'
    is_valid = 0
    for row in get_data(
            query=
            f"select lower(email) email, is_valid from crm.v_bot_users_all a where chat_type = 1 and user_id={user_id}"
    )['rows']:
        f_login = row['EMAIL']
        is_valid = int(row['IS_VALID'])
        if is_valid == 0:
            f_login = "******"
        else:
            f_login = ldap.get_data(search_filter=f_login,
                                    attr='sAMAccountName')
    return f_login