diff options
Diffstat (limited to 'app/api/menu-assignments/active-status')
| -rw-r--r-- | app/api/menu-assignments/active-status/route.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/api/menu-assignments/active-status/route.ts b/app/api/menu-assignments/active-status/route.ts new file mode 100644 index 00000000..bd31e6b8 --- /dev/null +++ b/app/api/menu-assignments/active-status/route.ts @@ -0,0 +1,32 @@ +// app/api/menu-assignments/active-status/route.ts + +import { NextResponse } from "next/server" +import db from "@/db/db" +import { menuAssignments } from "@/db/schema" +import { eq } from "drizzle-orm" + +export async function GET() { + try { + // 모든 메뉴의 활성 상태를 조회 + const menus = await db + .select({ + menuPath: menuAssignments.menuPath, + isActive: menuAssignments.isActive, + }) + .from(menuAssignments) + + // 객체 형태로 변환 { "/evcp/menu-path": true, "/evcp/other-path": false } + const activeMenusMap = menus.reduce((acc, menu) => { + acc[menu.menuPath] = menu.isActive + return acc + }, {} as Record<string, boolean>) + + return NextResponse.json(activeMenusMap) + } catch (error) { + console.error("Error fetching menu active status:", error) + return NextResponse.json( + { error: "Failed to fetch menu status" }, + { status: 500 } + ) + } +}
\ No newline at end of file |
