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

export const StockDataSchema = z.object({
  id: z.number().int('必须是整数').positive('必须是正整数').openapi({
    description: '股票数据ID',
    example: 1
  }),
  
  code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').openapi({
    description: '股票代码',
    example: '000001'
  }),
  
  data: z.array(z.any()).openapi({
    description: '股票数据',
    example: [{
      price: 10.5,
      volume: 1000,
      open: 10.2,
      close: 10.5,
      high: 10.8,
      low: 10.1
    }]
  }),
  
  createdAt: z.coerce.date('创建时间格式不正确').openapi({
    description: '创建时间',
    example: '2024-01-01T12:00:00Z'
  }),
  
  updatedAt: z.coerce.date('更新时间格式不正确').openapi({
    description: '更新时间',
    example: '2024-01-01T12:00:00Z'
  })
});

export const CreateStockDataDto = z.object({
  code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').openapi({
    description: '股票代码',
    example: '000001'
  }),
  
  data: z.array(z.any()).openapi({
    description: '股票数据',
    example: [{
      price: 10.5,
      volume: 1000,
      open: 10.2,
      close: 10.5,
      high: 10.8,
      low: 10.1
    }]
  })
});

export const UpdateStockDataDto = z.object({
  code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').optional().openapi({
    description: '股票代码',
    example: '000001'
  }),
  
  data: z.array(z.any()).openapi({
    description: '股票数据',
    example: [{
      price: 10.5,
      volume: 1000,
      open: 10.2,
      close: 10.5,
      high: 10.8,
      low: 10.1
    }]
  })
});