library-picturebook-activity/backend/scripts/check-contest-menus.ts
2026-01-09 18:14:35 +08:00

47 lines
1.3 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
// 查找赛事管理菜单
const contestMenu = await prisma.menu.findFirst({
where: { name: '赛事管理' }
});
console.log('📋 赛事管理菜单:', contestMenu ? `ID ${contestMenu.id}` : '不存在');
if (contestMenu) {
const children = await prisma.menu.findMany({
where: { parentId: contestMenu.id },
orderBy: { sort: 'asc' }
});
console.log('\n子菜单:');
if (children.length === 0) {
console.log(' (无子菜单)');
}
children.forEach(c => console.log(` - ${c.name} | ${c.path} | ${c.permission}`));
}
// 查找所有赛事相关菜单
console.log('\n📋 所有赛事相关菜单:');
const allContestMenus = await prisma.menu.findMany({
where: {
OR: [
{ path: { contains: 'contest' } },
{ name: { contains: '赛事' } },
{ name: { contains: '赛果' } },
{ name: { contains: '报名' } },
{ name: { contains: '作品' } },
]
},
orderBy: [{ parentId: 'asc' }, { sort: 'asc' }]
});
allContestMenus.forEach(m => {
const type = m.parentId ? ' (子)' : '(父)';
console.log(`${type} ${m.name} | ${m.path} | parentId: ${m.parentId}`);
});
}
main().catch(console.error).finally(() => prisma.$disconnect());