import { NextResponse } from "next/server";
import { queryRows } from "@/lib/db";
import { getSession } from "@/lib/session";

// 부서(팀) 목록 (dept_info) - 드롭다운용
export async function POST() {
  const user = await getSession();
  if (!user) return NextResponse.json({ success: false }, { status: 401 });

  const rows = await queryRows(
    `SELECT D.dept_code AS "DEPT_CODE",
       D.dept_name AS "DEPT_NAME"
     FROM dept_info D
     WHERE COALESCE(D.status, 'active') = 'active'
     ORDER BY D.dept_code
`,
  );
  return NextResponse.json({ RESULTLIST: rows });
}
