/**
 * 공정정보관리 라우트
 */

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

const router = Router();

router.use(authenticateToken);

// 공정 마스터 CRUD
router.get("/processes", ctrl.getProcessList);
router.post("/processes", ctrl.createProcess);
router.put("/processes/:id", ctrl.updateProcess);
router.post("/processes/delete", ctrl.deleteProcesses);

// 공정별 설비 관리
router.get("/processes/:processCode/equipments", ctrl.getProcessEquipments);
router.post("/process-equipments", ctrl.addProcessEquipment);
router.delete("/process-equipments/:id", ctrl.removeProcessEquipment);

// 설비 목록 (드롭다운용)
router.get("/equipments", ctrl.getEquipmentList);

// 품목 목록 (라우팅 등록된 품목만)
router.get("/items", ctrl.getItemsForRouting);

// 전체 품목 검색 (등록 모달용)
router.get("/items/search-all", ctrl.searchAllItems);

// 라우팅 버전
router.get("/routing-versions/:itemCode", ctrl.getRoutingVersions);
router.post("/routing-versions", ctrl.createRoutingVersion);
router.delete("/routing-versions/:id", ctrl.deleteRoutingVersion);

// 라우팅 상세
router.get("/routing-details/:versionId", ctrl.getRoutingDetails);
router.put("/routing-details/:versionId", ctrl.saveRoutingDetails);

// BOM 구성 자재 조회
router.get("/bom-materials/:itemCode", ctrl.getBomMaterials);

export default router;
