|
|
@@ -0,0 +1,98 @@
|
|
|
+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 })
|
|
|
+ id!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'classroom_no', type: 'varchar', length: 255, nullable: true, comment: '教室号' })
|
|
|
+ classroomNo!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'training_date', type: 'timestamp', nullable: true, comment: '训练日期' })
|
|
|
+ trainingDate!: Date | null;
|
|
|
+
|
|
|
+ @Column({ name: 'holding_stock', type: 'varchar', length: 255, nullable: true, comment: '持股' })
|
|
|
+ holdingStock!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'holding_cash', type: 'varchar', length: 255, nullable: true, comment: '持币' })
|
|
|
+ holdingCash!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'price', type: 'varchar', length: 255, nullable: true, comment: '价格' })
|
|
|
+ price!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'code', type: 'varchar', length: 255, nullable: true, comment: '代码' })
|
|
|
+ code!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'status', type: 'enum', enum:ClassroomStatus, nullable: true, comment: '状态' })
|
|
|
+ status!: ClassroomStatus | null;
|
|
|
+
|
|
|
+ @Column({ name: 'spare', type: 'varchar', length: 255, nullable: true, comment: '备用' })
|
|
|
+ spare!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'submit_user', type: 'varchar', length: 255, nullable: true, comment: '提交用户' })
|
|
|
+ submitUser!: string | null;
|
|
|
+
|
|
|
+ @Column({ name: 'created_by', type: 'int', nullable: true, comment: '创建用户ID' })
|
|
|
+ createdBy!: number | null;
|
|
|
+
|
|
|
+ @Column({ name: 'updated_by', type: 'int', nullable: true, comment: '更新用户ID' })
|
|
|
+ updatedBy!: number | null;
|
|
|
+
|
|
|
+ @Column({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
|
|
|
+ createdAt!: Date;
|
|
|
+
|
|
|
+ @Column({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP', onUpdate: 'CURRENT_TIMESTAMP' })
|
|
|
+ updatedAt!: Date;
|
|
|
+}
|
|
|
+
|
|
|
+export const ClassroomDataSchema = z.object({
|
|
|
+ id: z.number().int().positive().openapi({ description: '数据ID', example: 1 }),
|
|
|
+ classroomNo: z.string().max(255).nullable().openapi({ description: '教室号', example: 'test01' }),
|
|
|
+ trainingDate: z.date().nullable().openapi({ description: '训练日期', example: '2025-05-21T08:00:00Z' }),
|
|
|
+ holdingStock: z.string().max(255).nullable().openapi({ description: '持股', example: '100股' }),
|
|
|
+ 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.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: '' }),
|
|
|
+ createdBy: z.number().int().positive().nullable().openapi({ description: '创建用户ID', example: 1 }),
|
|
|
+ updatedBy: z.number().int().positive().nullable().openapi({ description: '更新用户ID', example: 1 }),
|
|
|
+ createdAt: z.date().openapi({ description: '创建时间', example: '2025-05-21T16:44:36Z' }),
|
|
|
+ updatedAt: z.date().openapi({ description: '更新时间', example: '2025-05-21T21:22:06Z' })
|
|
|
+});
|
|
|
+
|
|
|
+export const CreateClassroomDataDto = z.object({
|
|
|
+ classroomNo: z.string().max(255).optional().nullable().openapi({ description: '教室号', example: 'test01' }),
|
|
|
+ trainingDate: z.coerce.date().optional().nullable().openapi({ description: '训练日期', example: '2025-05-21T08:00:00Z' }),
|
|
|
+ holdingStock: z.string().max(255).optional().nullable().openapi({ description: '持股', example: '100股' }),
|
|
|
+ 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.nativeEnum(ClassroomStatus).optional().nullable().openapi({ description: '状态', example: ClassroomStatus.OPEN }),
|
|
|
+ spare: z.string().max(255).optional().nullable().openapi({ description: '备用', example: '' })
|
|
|
+});
|
|
|
+
|
|
|
+export const UpdateClassroomDataDto = z.object({
|
|
|
+ classroomNo: z.string().max(255).optional().nullable().openapi({ description: '教室号', example: 'test01' }),
|
|
|
+ trainingDate: z.coerce.date().optional().nullable().openapi({ description: '训练日期', example: '2025-05-21T08:00:00Z' }),
|
|
|
+ holdingStock: z.string().max(255).optional().nullable().openapi({ description: '持股', example: '100股' }),
|
|
|
+ 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.nativeEnum(ClassroomStatus).optional().nullable().openapi({ description: '状态', example: ClassroomStatus.OPEN }),
|
|
|
+ spare: z.string().max(255).optional().nullable().openapi({ description: '备用', example: '' })
|
|
|
+});
|