import express from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import {
  getMoldList,
  getMoldDetail,
  createMold,
  updateMold,
  deleteMold,
  getMoldSerials,
  createMoldSerial,
  deleteMoldSerial,
  getMoldInspections,
  createMoldInspection,
  deleteMoldInspection,
  getMoldParts,
  createMoldPart,
  deleteMoldPart,
  getMoldSerialSummary,
} from "../controllers/moldController";

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

// 금형 마스터
router.get("/", getMoldList);
router.get("/:moldCode", getMoldDetail);
router.post("/", createMold);
router.put("/:moldCode", updateMold);
router.delete("/:moldCode", deleteMold);

// 일련번호
router.get("/:moldCode/serials", getMoldSerials);
router.post("/:moldCode/serials", createMoldSerial);
router.delete("/serials/:id", deleteMoldSerial);

// 일련번호 현황 집계
router.get("/:moldCode/serial-summary", getMoldSerialSummary);

// 점검항목
router.get("/:moldCode/inspections", getMoldInspections);
router.post("/:moldCode/inspections", createMoldInspection);
router.delete("/inspections/:id", deleteMoldInspection);

// 부품
router.get("/:moldCode/parts", getMoldParts);
router.post("/:moldCode/parts", createMoldPart);
router.delete("/parts/:id", deleteMoldPart);

export default router;
