from app.models.base_model import SessionLocal
from app.service.v2.initialize_data import dialog_menu_sync, default_group_sync, default_role_sync, \
    basic_agent_sync, admin_account_sync, sync_rg_api_token, sync_complex_api_token, system_license_sync
from app.task.sync_account_token import sync_token


async def sync_default_data():
    db = SessionLocal()
    try:
        await dialog_menu_sync(db)  # 小数
        await default_group_sync(db)  # 默认组
        await default_role_sync(db)  # 默认角色
        await basic_agent_sync(db)  # 开发的agent
        await admin_account_sync(db)  # 管理员账号
        await sync_rg_api_token(db)  # rg token
        await sync_token()  # 账号token登录
        await sync_complex_api_token(db)  # 账号token同步
        await system_license_sync(db) # 同步系统license
    except Exception as e:
        print(e)
    finally:
        db.close()


