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

// 대상프로젝트번호 드롭다운용 프로젝트 목록
// 원본: common.xml getCusProjectNoList
export async function POST() {
  const user = await getSession();
  if (!user) return NextResponse.json({ success: false }, { status: 401 });

  const rows = await queryRows(
    `SELECT objid::varchar AS "CODE",
            project_no AS "NAME"
       FROM project_mgmt
      WHERE COALESCE(project_no,'') != ''
      ORDER BY project_no`
  );
  return NextResponse.json({ success: true, rows });
}
