const express = require('express');
const router = express.Router();
const pipeSpecController = require('../controllers/pipeSpecController');
const auth = require('../middlewares/auth');
const { requireAccess } = require('../middlewares/access');

// ✅ 전체 조회 (모든 사용자 가능)
router.get(
  '/',
  auth,
  requireAccess('worker', 'group_leader', 'support_team', 'admin', 'system'),
  pipeSpecController.getAll
);

// ✅ 재질 목록
router.get(
  '/materials',
  auth,
  requireAccess('worker', 'group_leader', 'support_team', 'admin', 'system'),
  pipeSpecController.getMaterials
);

// ✅ 직경 목록
router.get(
  '/diameters',
  auth,
  requireAccess('worker', 'group_leader', 'support_team', 'admin', 'system'),
  pipeSpecController.getDiameters
);

// ✅ 스케줄 목록
router.get(
  '/schedules',
  auth,
  requireAccess('worker', 'group_leader', 'support_team', 'admin', 'system'),
  pipeSpecController.getSchedules
);

// ✅ 등록 (시스템 또는 관리자만)
router.post(
  '/',
  auth,
  requireAccess('system', 'admin'),
  pipeSpecController.create
);

// ✅ 삭제 (시스템 또는 관리자만)
router.delete(
  '/:spec_id',
  auth,
  requireAccess('system', 'admin'),
  pipeSpecController.remove
);

module.exports = router;