const express = require('express');
const adminBookingRuleController = require('../controllers/adminBookingRuleController');
const { authenticateAdmin } = require('../middleware/auth');
const { requireAdmin } = require('../middleware/rbac');

const router = express.Router();

// Apply authentication middleware
router.use(authenticateAdmin);

/**
 * @route   GET /api/v1/admin/booking-rules
 * @desc    获取所有预约规则
 * @access  Private (Admin)
 */
router.get('/', requireAdmin, adminBookingRuleController.getAllRules);

/**
 * @route   GET /api/v1/admin/booking-rules/:serviceType
 * @desc    根据服务类型获取规则
 * @access  Private (Admin)
 */
router.get('/:serviceType', requireAdmin, adminBookingRuleController.getRuleByServiceType);

/**
 * @route   PUT /api/v1/admin/booking-rules/:serviceType
 * @desc    创建或更新预约规则
 * @access  Private (Admin)
 */
router.put('/:serviceType', requireAdmin, adminBookingRuleController.upsertRule);

/**
 * @route   POST /api/v1/admin/booking-rules/batch
 * @desc    批量更新预约规则
 * @access  Private (Admin)
 */
router.post('/batch', requireAdmin, adminBookingRuleController.batchUpsertRules);

/**
 * @route   DELETE /api/v1/admin/booking-rules/:serviceType
 * @desc    删除预约规则
 * @access  Private (Admin)
 */
router.delete('/:serviceType', requireAdmin, adminBookingRuleController.deleteRule);

module.exports = router;
