// 공급업체 목록 — supply_mng 재사용 (charger_type 같은 컬럼 없으므로 모든 supply_mng 행 노출)
import { NextResponse } from "next/server";
import { queryRows } from "@/lib/db";
import { requireMomoUser } from "@/lib/momo-guard";

export async function POST() {
  const r = await requireMomoUser();
  if (r instanceof NextResponse) return r;
  const rows = await queryRows(
    `SELECT objid AS "OBJID",
            supply_name AS "VENDOR_NAME",
            charge_user_name AS "CONTACT",
            supply_tel_no AS "PHONE",
            reg_no AS "BIZ_NO",
            email AS "EMAIL",
            supply_address AS "ADDRESS"
     FROM supply_mng
     WHERE COALESCE(status,'active') = 'active'
     ORDER BY supply_name ASC`
  );
  return NextResponse.json({ RESULTLIST: rows, TOTAL_CNT: rows.length });
}
