const express = require('express');
const router = express.Router();
const menuController = require('../controllers/menuController');
const { jwtAuth } = require('../middleware/auth');

/**
 * @swagger
 * tags:
 *   name: Menus
 *   description: 菜单管理相关接口
 */

// 移除了公共API路径，所有菜单API都需要认证

/**
 * @swagger
 * /api/menus:
 *   get:
 *     summary: 获取当前用户的菜单列表
 *     tags: [Menus]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取菜单列表
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 status:
 *                   type: string
 *                   example: success
 *                 data:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/Menu'
 *                 message:
 *                   type: string
 *                   example: 获取菜单成功
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/', jwtAuth, menuController.getMenus);

/**
 * @swagger
 * /api/menus/all:
 *   get:
 *     summary: 获取所有菜单（包括非激活状态，仅管理员可用）
 *     tags: [Menus]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取所有菜单
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 status:
 *                   type: string
 *                   example: success
 *                 data:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/Menu'
 *                 message:
 *                   type: string
 *                   example: 获取所有菜单成功
 *       401:
 *         description: 未授权
 *       403:
 *         description: 没有权限
 *       500:
 *         description: 服务器内部错误
 */
router.get('/all', jwtAuth, menuController.getAllMenus);

module.exports = router;