|
|
@@ -1,17 +1,5 @@
|
|
|
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]: '开放'
|
|
|
-};
|
|
|
+import { ClassroomStatus } from './classroom-data.schema';
|
|
|
|
|
|
@Entity('classroom_data')
|
|
|
export class ClassroomData {
|
|
|
@@ -56,43 +44,4 @@ export class ClassroomData {
|
|
|
|
|
|
@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: '' })
|
|
|
-});
|
|
|
+}
|