主要变更: - 将独立的 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>
34 lines
966 B
TypeScript
34 lines
966 B
TypeScript
import { defineEventHandler, readBody } from '#nitro';
|
|
|
|
import { MOCK_BUDGETS } from '../../utils/mock-data';
|
|
import { useResponseSuccess } from '../../utils/response';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody(event);
|
|
|
|
const newBudget = {
|
|
id: Date.now(),
|
|
userId: 1,
|
|
category: body.category,
|
|
categoryId: body.categoryId,
|
|
emoji: body.emoji,
|
|
limit: body.limit,
|
|
spent: body.spent || 0,
|
|
remaining: body.remaining || body.limit,
|
|
percentage: body.percentage || 0,
|
|
currency: body.currency,
|
|
period: body.period,
|
|
alertThreshold: body.alertThreshold,
|
|
description: body.description,
|
|
autoRenew: body.autoRenew,
|
|
overspendAlert: body.overspendAlert,
|
|
dailyReminder: body.dailyReminder,
|
|
monthlyTrend: body.monthlyTrend || 0,
|
|
createdAt: new Date().toISOString(),
|
|
isDeleted: false,
|
|
};
|
|
|
|
MOCK_BUDGETS.push(newBudget);
|
|
return useResponseSuccess(newBudget);
|
|
});
|