const express = require('express');
const router = express.Router();
const UnitController = require('../controllers/unitController');
const { authenticateToken, authorizePermission } = require('../middleware/auth');
const { createUnitValidation, updateUnitValidation } = require('../middleware/unitValidation');
// All routes require authentication
router.use(authenticateToken);
// GET /api/units - Get all units
router.get('/', authorizePermission('unit.read'), UnitController.getAllUnits);
// GET /api/units/statistics - Get unit statistics
router.get('/statistics', authorizePermission('unit.read'), UnitController.getUnitStatistics);
// GET /api/units/:id - Get unit by ID
router.get('/:id', UnitController.getUnitById);
// GET /api/units/:id/children - Get unit children
router.get('/:id/children', UnitController.getUnitChildren);
// POST /api/units - Create new unit (Permission-based)
router.post('/', authorizePermission('unit.create'), createUnitValidation, UnitController.createUnit);
// PUT /api/units/:id - Update unit (Permission-based)
router.put('/:id', authorizePermission('unit.update'), updateUnitValidation, UnitController.updateUnit);
// DELETE /api/units/:id - Delete unit (Permission-based)
router.delete('/:id', authorizePermission('unit.delete'), UnitController.deleteUnit);
module.exports = router;
//# sourceMappingURL=units.js.map