// ============================================================
// 생산관리 > M-BOM 관리 라우트.
// app.ts: app.use("/api/production/mbom", productionMbomRoutes)
// ============================================================

import { Router } from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import * as ctrl from "../controllers/mbomController";

const router = Router();
router.use(authenticateToken);

router.get("/list",         ctrl.getList);
router.get("/detail/:objid", ctrl.getDetail);
router.get("/tree/:objid",   ctrl.getTree);
router.post("/save",         ctrl.save);            // PR-B1 본 편집 저장
router.get("/history/:projectObjid", ctrl.getHistory); // PR-B4 변경이력 조회
router.post("/sales-request", ctrl.createSalesRequest); // PR-B3 구매리스트 생성
router.get("/assignable-eboms", ctrl.searchAssignableEboms); // PR-B5 할당 가능 E-BOM 검색
router.get("/ebom-preview/:bomReportObjid", ctrl.previewEbomTree); // PR-B5 E-BOM 미리보기
router.post("/assign",       ctrl.assignBom);        // PR-B5 BOM 할당
router.get("/assignable-mboms", ctrl.searchAssignableMboms); // PR-B5+ BOM 복사 - M-BOM 셀렉트 옵션
router.get("/mbom-preview/:mbomHeaderObjid", ctrl.previewMbomTree); // PR-B5+ BOM 복사 - M-BOM 미리보기
router.get("/latest-mbom-by-partno/:partNo", ctrl.getLatestMbomByPartNo); // PR-B5+ Machine 외 자동 추천

export default router;
