主要变更: - 将独立的 web-finance 应用整合到 web-antd 主应用中 - 重命名 backend-mock 为 backend,增强后端功能 - 新增财务模块 API 端点(账户、预算、类别、交易) - 增强财务仪表板和报表功能 - 添加 SQLite 数据存储支持和财务数据导入脚本 - 优化路由结构,删除冗余的 finance-system 模块 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
938 B
TypeScript
31 lines
938 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) => (rate.date > max ? rate.date : max), rates[0].date);
|
|
rates = rates.filter((rate) => rate.date === latestDate);
|
|
}
|
|
|
|
return useResponseSuccess(rates);
|
|
});
|