// routes/toolsRoute.js
const express = require('express');
const router = express.Router();
const controller = require('../controllers/toolsController');
const { requireAuth } = require('../middlewares/auth');
const { createRequirePage } = require('../../../shared/middleware/pagePermission');
const { getDb } = require('../dbPool');
const requirePage = createRequirePage(getDb);

// 읽기 작업: 인증된 사용자
router.get('/', requireAuth, controller.getAll);
router.get('/:id', requireAuth, controller.getById);

// 쓰기 작업: group_leader 이상 권한 필요
router.post('/', requireAuth, requirePage('factory_tools'), controller.create);
router.put('/:id', requireAuth, requirePage('factory_tools'), controller.update);
router.delete('/:id', requireAuth, requirePage('factory_tools'), controller.delete);

module.exports = router;
