feat: migrate backend storage to postgres
Some checks failed
Deploy to Production / Build and Test (push) Successful in 10m51s
Deploy to Production / Deploy to Server (push) Failing after 6m41s

This commit is contained in:
你的用户名
2025-11-06 22:01:50 +08:00
parent 3646405a47
commit b68511b2e2
28 changed files with 2641 additions and 1801 deletions

View File

@@ -1,20 +1,19 @@
import type { TransactionStatus } from '~/utils/finance-repository';
import { readBody } from 'h3';
import {
createTransaction,
type TransactionStatus,
} from '~/utils/finance-repository';
import { createTransaction } from '~/utils/finance-repository';
import { useResponseError, useResponseSuccess } from '~/utils/response';
import { notifyTransactionWebhook } from '~/utils/telegram-webhook';
const DEFAULT_CURRENCY = 'CNY';
const DEFAULT_STATUS: TransactionStatus = 'pending';
const ALLOWED_STATUSES: TransactionStatus[] = [
const ALLOWED_STATUSES = new Set<TransactionStatus>([
'draft',
'pending',
'approved',
'rejected',
'paid',
];
]);
export default defineEventHandler(async (event) => {
const body = await readBody(event);
@@ -33,11 +32,11 @@ export default defineEventHandler(async (event) => {
const status =
(body.status as TransactionStatus | undefined) ?? DEFAULT_STATUS;
if (!ALLOWED_STATUSES.includes(status)) {
if (!ALLOWED_STATUSES.has(status)) {
return useResponseError('状态值不合法', -1);
}
const reimbursement = createTransaction({
const reimbursement = await createTransaction({
type,
amount,
currency: body.currency ?? DEFAULT_CURRENCY,