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

/**
 * @swagger
 * tags:
 *   name: DataWarehouse
 *   description: 数据览仓相关接口
 */

/**
 * @swagger
 * /api/data-warehouse/overview:
 *   get:
 *     summary: 获取数据览仓概览数据
 *     tags: [DataWarehouse]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取概览数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code: { type: 'number' }
 *                 status: { type: 'string' }
 *                 data: { type: 'object' }
 *                 message: { type: 'string' }
 *                 timestamp: { type: 'string' }
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/overview', jwtAuth, checkPermission('data', 'read'), 
  dataWarehouseController.getOverview
);

/**
 * @swagger
 * /api/data-warehouse/insurance-type-distribution:
 *   get:
 *     summary: 获取保险类型分布数据
 *     tags: [DataWarehouse]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取保险类型分布数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code: { type: 'number' }
 *                 status: { type: 'string' }
 *                 data: { type: 'array' }
 *                 message: { type: 'string' }
 *                 timestamp: { type: 'string' }
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/insurance-type-distribution', jwtAuth, checkPermission('data', 'read'), 
  dataWarehouseController.getInsuranceTypeDistribution
);

/**
 * @swagger
 * /api/data-warehouse/application-status-distribution:
 *   get:
 *     summary: 获取申请状态分布数据
 *     tags: [DataWarehouse]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取申请状态分布数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code: { type: 'number' }
 *                 status: { type: 'string' }
 *                 data: { type: 'array' }
 *                 message: { type: 'string' }
 *                 timestamp: { type: 'string' }
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/application-status-distribution', jwtAuth, checkPermission('data', 'read'), 
  dataWarehouseController.getApplicationStatusDistribution
);

/**
 * @swagger
 * /api/data-warehouse/trend-data:
 *   get:
 *     summary: 获取近7天趋势数据
 *     tags: [DataWarehouse]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取趋势数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code: { type: 'number' }
 *                 status: { type: 'string' }
 *                 data: { type: 'array' }
 *                 message: { type: 'string' }
 *                 timestamp: { type: 'string' }
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/trend-data', jwtAuth, checkPermission('data', 'read'), 
  dataWarehouseController.getTrendData
);

/**
 * @swagger
 * /api/data-warehouse/claim-stats:
 *   get:
 *     summary: 获取赔付统计数据
 *     tags: [DataWarehouse]
 *     security:
 *       - bearerAuth: []
 *     responses:
 *       200:
 *         description: 成功获取赔付统计数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code: { type: 'number' }
 *                 status: { type: 'string' }
 *                 data: { type: 'array' }
 *                 message: { type: 'string' }
 *                 timestamp: { type: 'string' }
 *       401:
 *         description: 未授权
 *       500:
 *         description: 服务器内部错误
 */
router.get('/claim-stats', jwtAuth, checkPermission('data', 'read'), 
  dataWarehouseController.getClaimStats
);

module.exports = router;