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

// 양산제품코드 목록 (product_mgmt) - 드롭다운용
export async function POST(request: NextRequest) {
  const user = await getSession();
  if (!user) return NextResponse.json({ success: false }, { status: 401 });

  const rows = await queryRows(
    `SELECT objid::text AS "OBJID",
       product_code AS "PRODUCT_CODE",
       product_code AS "NAME"
     FROM product_mgmt
     ORDER BY product_code
`,
  );
  return NextResponse.json({ RESULTLIST: rows });
}
