import { Router } from 'express';
import { requireTraceContext } from '../../core/guards/trace-context.guard';
import { requirePermission } from '../../core/guards/rbac.guard';
import { CurrencyController } from '../controllers/CurrencyController';

const router = Router();

// 货币管理路由
router.get('/currencies', CurrencyController.getCurrencies);
router.get('/currencies/:code', CurrencyController.getCurrencyByCode);
router.get('/currencies/default', CurrencyController.getDefaultCurrency);
router.post('/currencies', requireTraceContext, requirePermission('currency:write'), CurrencyController.createCurrency);
router.put('/currencies/:id', requireTraceContext, requirePermission('currency:write'), CurrencyController.updateCurrency);
router.patch('/currencies/:id/deactivate', requireTraceContext, requirePermission('currency:write'), CurrencyController.deactivateCurrency);
router.patch('/currencies/:id/set-default', requireTraceContext, requirePermission('currency:write'), CurrencyController.setDefaultCurrency);

// 汇率管理路由
router.get('/exchange-rates/:from/:to', CurrencyController.getExchangeRate);
router.get('/exchange-rates', CurrencyController.getAllExchangeRates);
router.post('/exchange-rates/update', requireTraceContext, requirePermission('currency:write'), CurrencyController.updateExchangeRates);
router.get('/exchange-rates/history/:from/:to', CurrencyController.getExchangeRateHistory);

// 货币转换路由
router.post('/convert', CurrencyController.convertCurrency);
router.post('/convert/multiple', CurrencyController.convertMultipleCurrencies);
router.post('/convert/to-default', CurrencyController.convertToDefaultCurrency);
router.post('/convert/from-default', CurrencyController.convertFromDefaultCurrency);

// 货币计算路由
router.post('/calculate/price', CurrencyController.calculatePrice);
router.post('/calculate/profit', CurrencyController.calculateProfit);
router.post('/calculate/profit-percentage', CurrencyController.calculateProfitPercentage);
router.post('/calculate/break-even', CurrencyController.calculateBreakEvenPrice);
router.post('/calculate/markup-percentage', CurrencyController.calculateMarkupPercentage);

export default router;
