|
|
@@ -1,6 +1,18 @@
|
|
|
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
|
|
|
|
+// 教室状态枚举
|
|
|
+export enum ClassroomStatus {
|
|
|
+ CLOSED = 0, // 关闭
|
|
|
+ OPEN = 1 // 开放
|
|
|
+}
|
|
|
+
|
|
|
+// 教室状态中文映射
|
|
|
+export const ClassroomStatusNameMap: Record<ClassroomStatus, string> = {
|
|
|
+ [ClassroomStatus.CLOSED]: '关闭',
|
|
|
+ [ClassroomStatus.OPEN]: '开放'
|
|
|
+};
|
|
|
+
|
|
|
@Entity('classroom_data')
|
|
|
export class ClassroomData {
|
|
|
@PrimaryGeneratedColumn({ unsigned: true })
|
|
|
@@ -24,8 +36,8 @@ export class ClassroomData {
|
|
|
@Column({ name: 'code', type: 'varchar', length: 255, nullable: true, comment: '代码' })
|
|
|
code!: string | null;
|
|
|
|
|
|
- @Column({ name: 'status', type: 'varchar', length: 255, nullable: true, comment: '状态' })
|
|
|
- status!: string | null;
|
|
|
+ @Column({ name: 'status', type: 'enum', enum:ClassroomStatus, length: 255, nullable: true, comment: '状态' })
|
|
|
+ status!: ClassroomStatus | null;
|
|
|
|
|
|
@Column({ name: 'spare', type: 'varchar', length: 255, nullable: true, comment: '备用' })
|
|
|
spare!: string | null;
|
|
|
@@ -48,7 +60,7 @@ export const ClassroomDataSchema = z.object({
|
|
|
holdingCash: z.string().max(255).nullable().openapi({ description: '持币', example: '10000元' }),
|
|
|
price: z.string().max(255).nullable().openapi({ description: '价格', example: '15.68' }),
|
|
|
code: z.string().max(255).nullable().openapi({ description: '代码', example: '001339' }),
|
|
|
- status: z.string().max(255).nullable().openapi({ description: '状态', example: '1' }),
|
|
|
+ status: z.nativeEnum(ClassroomStatus).nullable().openapi({ description: '状态', example: ClassroomStatus.OPEN }),
|
|
|
spare: z.string().max(255).nullable().openapi({ description: '备用', example: '' }),
|
|
|
submitUser: z.string().max(255).nullable().openapi({ description: '提交用户', example: '' }),
|
|
|
createdAt: z.date().openapi({ description: '创建时间', example: '2025-05-21T16:44:36Z' }),
|
|
|
@@ -62,7 +74,7 @@ export const CreateClassroomDataDto = z.object({
|
|
|
holdingCash: z.string().max(255).optional().nullable().openapi({ description: '持币', example: '10000元' }),
|
|
|
price: z.string().max(255).optional().nullable().openapi({ description: '价格', example: '15.68' }),
|
|
|
code: z.string().max(255).optional().nullable().openapi({ description: '代码', example: '001339' }),
|
|
|
- status: z.string().max(255).optional().nullable().openapi({ description: '状态', example: '1' }),
|
|
|
+ status: z.nativeEnum(ClassroomStatus).optional().nullable().openapi({ description: '状态', example: ClassroomStatus.OPEN }),
|
|
|
spare: z.string().max(255).optional().nullable().openapi({ description: '备用', example: '' }),
|
|
|
submitUser: z.string().max(255).optional().nullable().openapi({ description: '提交用户', example: '' })
|
|
|
});
|
|
|
@@ -74,7 +86,7 @@ export const UpdateClassroomDataDto = z.object({
|
|
|
holdingCash: z.string().max(255).optional().nullable().openapi({ description: '持币', example: '10000元' }),
|
|
|
price: z.string().max(255).optional().nullable().openapi({ description: '价格', example: '15.68' }),
|
|
|
code: z.string().max(255).optional().nullable().openapi({ description: '代码', example: '001339' }),
|
|
|
- status: z.string().max(255).optional().nullable().openapi({ description: '状态', example: '1' }),
|
|
|
+ status: z.nativeEnum(ClassroomStatus).optional().nullable().openapi({ description: '状态', example: ClassroomStatus.OPEN }),
|
|
|
spare: z.string().max(255).optional().nullable().openapi({ description: '备用', example: '' }),
|
|
|
submitUser: z.string().max(255).optional().nullable().openapi({ description: '提交用户', example: '' })
|
|
|
});
|