import { z } from '@hono/zod-openapi';

// 股票训练代码实体Schema定义
export const StockXunlianCodesSchema = z.object({
  id: z.number()
    .int('ID必须是整数')
    .positive('ID必须是正整数')
    .openapi({
      description: '股票训练代码ID',
      example: 1
    }),
    
  code: z.string()
    .min(1, '股票代码不能为空')
    .max(255, '股票代码最多255个字符')
    .openapi({
      description: '股票代码',
      example: '000001'
    }),
    
  stockName: z.string()
    .min(1, '股票名称不能为空')
    .max(255, '股票名称最多255个字符')
    .openapi({
      description: '股票名称',
      example: '平安银行'
    }),
    
  name: z.string()
    .min(1, '案例名称不能为空')
    .max(255, '案例名称最多255个字符')
    .openapi({
      description: '案例名称',
      example: '平安银行2024年走势分析'
    }),
    
  type: z.string()
    .max(255, '案例类型最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例类型',
      example: '技术分析'
    }),
    
  description: z.string()
    .max(255, '案例描述最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例描述',
      example: '基于MACD指标的技术分析案例'
    }),
    
  trainingStartDate: z.coerce.date<Date>()
    .openapi({
      description: '训练开始日期',
      example: '2024-01-01'
    }),

  trainingEndDate: z.coerce.date<Date>()
    .openapi({
      description: '训练结束日期',
      example: '2024-12-31'
    }),
    
  createdAt: z.coerce.date<Date>()
    .openapi({
      description: '创建时间',
      example: '2024-01-15T10:30:00Z'
    }),
    
  updatedAt: z.coerce.date<Date>()
    .openapi({
      description: '更新时间',
      example: '2024-01-15T10:30:00Z'
    })
});

// 创建股票训练代码DTO
export const CreateStockXunlianCodesDto = z.object({
  code: z.string()
    .min(1, '股票代码不能为空')
    .max(255, '股票代码最多255个字符')
    .openapi({
      description: '股票代码',
      example: '000001'
    }),
    
  stockName: z.string()
    .min(1, '股票名称不能为空')
    .max(255, '股票名称最多255个字符')
    .openapi({
      description: '股票名称',
      example: '平安银行'
    }),
    
  name: z.string()
    .min(1, '案例名称不能为空')
    .max(255, '案例名称最多255个字符')
    .openapi({
      description: '案例名称',
      example: '平安银行2024年走势分析'
    }),
    
  type: z.string()
    .max(255, '案例类型最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例类型',
      example: '技术分析'
    }),
    
  description: z.string()
    .max(255, '案例描述最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例描述',
      example: '基于MACD指标的技术分析案例'
    }),
    
  trainingStartDate: z.coerce.date<Date>()
    .openapi({
      description: '训练开始日期',
      example: '2024-01-01'
    }),

  trainingEndDate: z.coerce.date<Date>()
    .openapi({
      description: '训练结束日期',
      example: '2024-12-31'
    })
});

// 更新股票训练代码DTO
export const UpdateStockXunlianCodesDto = z.object({
  code: z.string()
    .min(1, '股票代码不能为空')
    .max(255, '股票代码最多255个字符')
    .optional()
    .openapi({
      description: '股票代码',
      example: '000001'
    }),
    
  stockName: z.string()
    .min(1, '股票名称不能为空')
    .max(255, '股票名称最多255个字符')
    .optional()
    .openapi({
      description: '股票名称',
      example: '平安银行'
    }),
    
  name: z.string()
    .min(1, '案例名称不能为空')
    .max(255, '案例名称最多255个字符')
    .optional()
    .openapi({
      description: '案例名称',
      example: '平安银行2024年走势分析'
    }),
    
  type: z.string()
    .max(255, '案例类型最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例类型',
      example: '技术分析'
    }),
    
  description: z.string()
    .max(255, '案例描述最多255个字符')
    .nullable()
    .optional()
    .openapi({
      description: '案例描述',
      example: '基于MACD指标的技术分析案例'
    }),
    
  trainingStartDate: z.coerce.date<Date>()
    .optional()
    .openapi({
      description: '训练开始日期',
      example: '2024-01-01'
    }),

  trainingEndDate: z.coerce.date<Date>()
    .optional()
    .openapi({
      description: '训练结束日期',
      example: '2024-12-31'
    })
});