|
@@ -1,10 +1,10 @@
|
|
|
-import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
|
|
|
|
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
import { z } from '@hono/zod-openapi';
|
|
|
|
|
|
|
|
@Entity('expense')
|
|
@Entity('expense')
|
|
|
export class Expense {
|
|
export class Expense {
|
|
|
- @PrimaryColumn({ name: 'id', type: 'varchar', length: 50 })
|
|
|
|
|
- id!: string;
|
|
|
|
|
|
|
+ @PrimaryGeneratedColumn({ unsigned: true })
|
|
|
|
|
+ id!: number;
|
|
|
|
|
|
|
|
@Column({ name: 'expense_date', type: 'date' })
|
|
@Column({ name: 'expense_date', type: 'date' })
|
|
|
expenseDate!: Date;
|
|
expenseDate!: Date;
|
|
@@ -70,9 +70,9 @@ export class Expense {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const ExpenseSchema = z.object({
|
|
export const ExpenseSchema = z.object({
|
|
|
- id: z.string().max(50).openapi({
|
|
|
|
|
|
|
+ id: z.number().int().positive().openapi({
|
|
|
description: '费用记录ID',
|
|
description: '费用记录ID',
|
|
|
- example: 'EXP20230001'
|
|
|
|
|
|
|
+ example: 1
|
|
|
}),
|
|
}),
|
|
|
expenseDate: z.date().openapi({
|
|
expenseDate: z.date().openapi({
|
|
|
description: '费用发生日期',
|
|
description: '费用发生日期',
|
|
@@ -153,10 +153,7 @@ export const ExpenseSchema = z.object({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
export const CreateExpenseDto = z.object({
|
|
export const CreateExpenseDto = z.object({
|
|
|
- id: z.string().max(50).openapi({
|
|
|
|
|
- description: '费用记录ID',
|
|
|
|
|
- example: 'EXP20230001'
|
|
|
|
|
- }),
|
|
|
|
|
|
|
+
|
|
|
expenseDate: z.coerce.date().openapi({
|
|
expenseDate: z.coerce.date().openapi({
|
|
|
description: '费用发生日期',
|
|
description: '费用发生日期',
|
|
|
example: '2023-01-15'
|
|
example: '2023-01-15'
|