refactor: 整合财务系统到主应用并重构后端架构
主要变更: - 将独立的 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>
This commit is contained in:
18
apps/backend/api/finance/categories/[id].delete.ts
Normal file
18
apps/backend/api/finance/categories/[id].delete.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getRouterParam } from 'h3';
|
||||
|
||||
import { deleteCategoryRecord } from '~/utils/finance-metadata';
|
||||
import { useResponseError, useResponseSuccess } from '~/utils/response';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = Number(getRouterParam(event, 'id'));
|
||||
if (Number.isNaN(id)) {
|
||||
return useResponseError('参数错误', -1);
|
||||
}
|
||||
|
||||
const deleted = deleteCategoryRecord(id);
|
||||
if (!deleted) {
|
||||
return useResponseError('分类不存在', -1);
|
||||
}
|
||||
|
||||
return useResponseSuccess({ message: '删除成功' });
|
||||
});
|
||||
27
apps/backend/api/finance/categories/[id].put.ts
Normal file
27
apps/backend/api/finance/categories/[id].put.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { getRouterParam, readBody } from 'h3';
|
||||
|
||||
import { updateCategoryRecord } from '~/utils/finance-metadata';
|
||||
import { useResponseError, useResponseSuccess } from '~/utils/response';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = Number(getRouterParam(event, 'id'));
|
||||
if (Number.isNaN(id)) {
|
||||
return useResponseError('参数错误', -1);
|
||||
}
|
||||
|
||||
const body = await readBody(event);
|
||||
|
||||
const updated = updateCategoryRecord(id, {
|
||||
name: body?.name,
|
||||
icon: body?.icon,
|
||||
color: body?.color,
|
||||
userId: body?.userId,
|
||||
isActive: body?.isActive,
|
||||
});
|
||||
|
||||
if (!updated) {
|
||||
return useResponseError('分类不存在', -1);
|
||||
}
|
||||
|
||||
return useResponseSuccess(updated);
|
||||
});
|
||||
Reference in New Issue
Block a user