84 lines
3.0 KiB
Python
84 lines
3.0 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""检查系统菜单配置"""
|
||
|
|
|
||
|
|
import asyncio
|
||
|
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||
|
|
from sqlalchemy import text
|
||
|
|
|
||
|
|
DB_CONFIG = {
|
||
|
|
'host': '123.57.81.127',
|
||
|
|
'port': 3306,
|
||
|
|
'user': 'cpy_admin',
|
||
|
|
'password': 'Tgzz2025+',
|
||
|
|
'database': 'ruoyi-fastapi'
|
||
|
|
}
|
||
|
|
|
||
|
|
DATABASE_URL = (
|
||
|
|
f"mysql+asyncmy://{DB_CONFIG['user']}:{DB_CONFIG['password']}@"
|
||
|
|
f"{DB_CONFIG['host']}:{DB_CONFIG['port']}/{DB_CONFIG['database']}"
|
||
|
|
)
|
||
|
|
|
||
|
|
async def check_menus():
|
||
|
|
engine = create_async_engine(DATABASE_URL, echo=False)
|
||
|
|
|
||
|
|
async with engine.connect() as conn:
|
||
|
|
print("=" * 80)
|
||
|
|
print("System Menu Configuration")
|
||
|
|
print("=" * 80)
|
||
|
|
|
||
|
|
# 1. 检查测试类别相关菜单
|
||
|
|
print("\n[1] Test Category Related Menus:")
|
||
|
|
result = await conn.execute(text("""
|
||
|
|
SELECT menu_id, menu_name, parent_id, order_num, path, component, menu_type, visible, perms
|
||
|
|
FROM sys_menu
|
||
|
|
WHERE menu_name LIKE '%测试%' OR menu_name LIKE '%类别%' OR path LIKE '%test_category%'
|
||
|
|
ORDER BY parent_id, order_num
|
||
|
|
"""))
|
||
|
|
rows = result.fetchall()
|
||
|
|
for row in rows:
|
||
|
|
print(f" ID:{row[0]} | {row[1]:<15} | Parent:{row[2]} | Path:{row[4]:<30} | Type:{row[6]} | Perms:{row[8]}")
|
||
|
|
|
||
|
|
# 2. 检查工单领取相关菜单
|
||
|
|
print("\n[2] Work Order Claim Related Menus:")
|
||
|
|
result = await conn.execute(text("""
|
||
|
|
SELECT menu_id, menu_name, parent_id, order_num, path, component, menu_type, visible, perms
|
||
|
|
FROM sys_menu
|
||
|
|
WHERE menu_name LIKE '%工单%' OR menu_name LIKE '%领取%' OR path LIKE '%workorder%' OR path LIKE '%claim%'
|
||
|
|
ORDER BY parent_id, order_num
|
||
|
|
"""))
|
||
|
|
rows = result.fetchall()
|
||
|
|
for row in rows:
|
||
|
|
print(f" ID:{row[0]} | {row[1]:<15} | Parent:{row[2]} | Path:{row[4]:<30} | Type:{row[6]} | Perms:{row[8]}")
|
||
|
|
|
||
|
|
# 3. 检查所有一级菜单
|
||
|
|
print("\n[3] All Top-Level Menus:")
|
||
|
|
result = await conn.execute(text("""
|
||
|
|
SELECT menu_id, menu_name, order_num, path, icon
|
||
|
|
FROM sys_menu
|
||
|
|
WHERE parent_id = 0
|
||
|
|
ORDER BY order_num
|
||
|
|
"""))
|
||
|
|
rows = result.fetchall()
|
||
|
|
for row in rows:
|
||
|
|
print(f" ID:{row[0]} | {row[1]:<15} | Order:{row[2]} | Icon:{row[4]}")
|
||
|
|
|
||
|
|
# 4. 检查系统管理下的子菜单
|
||
|
|
print("\n[4] System Management Sub-menus:")
|
||
|
|
result = await conn.execute(text("""
|
||
|
|
SELECT m.menu_id, m.menu_name, m.parent_id, m.order_num, m.path, m.component, m.perms
|
||
|
|
FROM sys_menu m
|
||
|
|
JOIN sys_menu p ON m.parent_id = p.menu_id
|
||
|
|
WHERE p.menu_name = '系统管理'
|
||
|
|
ORDER BY m.order_num
|
||
|
|
"""))
|
||
|
|
rows = result.fetchall()
|
||
|
|
for row in rows:
|
||
|
|
print(f" ID:{row[0]} | {row[1]:<20} | Path:{row[4]:<30} | Component:{row[5]}")
|
||
|
|
|
||
|
|
print("\n" + "=" * 80)
|
||
|
|
|
||
|
|
await engine.dispose()
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
asyncio.run(check_menus())
|