Files
kt-financial-system/apps/backend/api/finance/exchange-rates.get.ts
woshiqp465 1def26f74f feat: 更新财务系统功能和界面优化
- 优化财务仪表板数据展示
- 增强账户管理功能
- 改进预算和分类管理
- 完善报表和统计分析
- 优化交易管理界面
- 更新Workspace工作区

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-05 15:10:06 +08:00

33 lines
945 B
TypeScript

import { getQuery } from 'h3';
import { listExchangeRates } from '~/utils/finance-metadata';
import { useResponseSuccess } from '~/utils/response';
export default defineEventHandler(async (event) => {
const query = getQuery(event);
const fromCurrency = query.from as string | undefined;
const toCurrency = query.to as string | undefined;
const date = query.date as string | undefined;
let rates = listExchangeRates();
if (fromCurrency) {
rates = rates.filter((rate) => rate.fromCurrency === fromCurrency);
}
if (toCurrency) {
rates = rates.filter((rate) => rate.toCurrency === toCurrency);
}
if (date) {
rates = rates.filter((rate) => rate.date === date);
} else if (rates.length > 0) {
const latestDate = rates.reduce(
(max, rate) => Math.max(rate.date, max),
rates[0].date,
);
rates = rates.filter((rate) => rate.date === latestDate);
}
return useResponseSuccess(rates);
});