add backend source code
This commit is contained in:
26
backend/create_menu_tables.py
Normal file
26
backend/create_menu_tables.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
创建菜单管理表并初始化默认菜单
|
||||
"""
|
||||
import asyncio
|
||||
from app.core.database import engine, Base
|
||||
from app.models.models import Menu
|
||||
from app.services.menu_service import MenuService
|
||||
|
||||
|
||||
async def create_tables_and_init():
|
||||
"""创建表并初始化菜单"""
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
print("数据库表创建成功!")
|
||||
|
||||
# 初始化默认菜单
|
||||
async with async_session_maker() as session:
|
||||
await MenuService.init_default_menus(session)
|
||||
|
||||
print("默认菜单初始化成功!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from app.core.database import async_session_maker
|
||||
asyncio.run(create_tables_and_init())
|
||||
Reference in New Issue
Block a user