Просмотр исходного кода

✨ feat(stock): 创建股票训练代码实体及相关DTO

- 创建StockXunlianCodes实体类,定义股票训练代码数据表结构
- 添加id、code、stockName等字段,包含创建时间和更新时间戳
- 定义StockXunlianCodesSchema验证模式
- 创建CreateStockXunlianCodesDto和UpdateStockXunlianCodesDto数据传输对象
yourname 5 месяцев назад
Родитель
Сommit
5bfb599785
1 измененных файлов с 62 добавлено и 0 удалено
  1. 62 0
      src/server/modules/stock/stock-xunlian-codes.entity.ts

+ 62 - 0
src/server/modules/stock/stock-xunlian-codes.entity.ts

@@ -0,0 +1,62 @@
+import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
+import { z } from '@hono/zod-openapi';
+
+@Entity('stock_xunlian_codes')
+export class StockXunlianCodes {
+  @PrimaryGeneratedColumn({ unsigned: true })
+  id!: number;
+
+  @Column({ name: 'code', type: 'varchar', length: 255, nullable: false, comment: '股票代码' })
+  code!: string;
+
+  @Column({ name: 'stock_name', type: 'varchar', length: 255, nullable: false, comment: '股票名称' })
+  stockName!: string;
+
+  @Column({ name: 'name', type: 'varchar', length: 255, nullable: false, comment: '案例名称' })
+  name!: string;
+
+  @Column({ name: 'type', type: 'varchar', length: 255, nullable: true, comment: '案例类型' })
+  type!: string | null;
+
+  @Column({ name: 'description', type: 'varchar', length: 255, nullable: true, comment: '案例描述' })
+  description!: string | null;
+
+  @Column({ name: 'trade_date', type: 'timestamp', nullable: false, comment: '交易日期' })
+  tradeDate!: Date;
+
+  @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 StockXunlianCodesSchema = z.object({
+  id: z.number().int().positive().openapi({ description: 'ID', example: 1 }),
+  code: z.string().max(255).openapi({ description: '股票代码', example: '001339' }),
+  stockName: z.string().max(255).openapi({ description: '股票名称', example: 'test01' }),
+  name: z.string().max(255).openapi({ description: '案例名称', example: 'test222' }),
+  type: z.string().max(255).nullable().openapi({ description: '案例类型', example: '技术分析' }),
+  description: z.string().max(255).nullable().openapi({ description: '案例描述', example: '这是一个测试案例' }),
+  tradeDate: z.date().openapi({ description: '交易日期', example: '2025-05-21T08:00:00Z' }),
+  createdAt: z.date().openapi({ description: '创建时间', example: '2025-05-22T16:58:01Z' }),
+  updatedAt: z.date().openapi({ description: '更新时间', example: '2025-05-22T17:19:32Z' })
+});
+
+export const CreateStockXunlianCodesDto = z.object({
+  code: z.string().max(255).openapi({ description: '股票代码', example: '001339' }),
+  stockName: z.string().max(255).openapi({ description: '股票名称', example: 'test01' }),
+  name: z.string().max(255).openapi({ description: '案例名称', example: 'test222' }),
+  type: z.string().max(255).nullable().openapi({ description: '案例类型', example: '技术分析' }),
+  description: z.string().max(255).nullable().openapi({ description: '案例描述', example: '这是一个测试案例' }),
+  tradeDate: z.date().openapi({ description: '交易日期', example: '2025-05-21T08:00:00Z' })
+});
+
+export const UpdateStockXunlianCodesDto = z.object({
+  code: z.string().max(255).optional().openapi({ description: '股票代码', example: '001339' }),
+  stockName: z.string().max(255).optional().openapi({ description: '股票名称', example: 'test01' }),
+  name: z.string().max(255).optional().openapi({ description: '案例名称', example: 'test222' }),
+  type: z.string().max(255).nullable().optional().openapi({ description: '案例类型', example: '技术分析' }),
+  description: z.string().max(255).nullable().optional().openapi({ description: '案例描述', example: '这是一个测试案例' }),
+  tradeDate: z.date().optional().openapi({ description: '交易日期', example: '2025-05-21T08:00:00Z' })
+});