2
0

date-notes.schema.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { z } from '@hono/zod-openapi';
  2. export const DateNotesSchema = z.object({
  3. id: z.number().int('ID必须是整数').positive('ID必须是正整数').openapi({
  4. description: '日期备注ID',
  5. example: 1
  6. }),
  7. code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').openapi({
  8. description: '股票代码',
  9. example: '600000'
  10. }),
  11. noteDate: z.coerce.date<Date>('备注日期格式不正确').openapi({
  12. description: '备注日期',
  13. example: '2024-01-15T00:00:00Z'
  14. }),
  15. note: z.string().min(1, '备注内容不能为空').max(255, '备注内容最多255个字符').openapi({
  16. description: '备注内容',
  17. example: '重点关注该股票走势'
  18. }),
  19. createdAt: z.coerce.date('创建时间格式不正确').openapi({
  20. description: '创建时间',
  21. example: '2024-01-15T10:30:00Z'
  22. }),
  23. updatedAt: z.coerce.date('更新时间格式不正确').openapi({
  24. description: '更新时间',
  25. example: '2024-01-15T10:30:00Z'
  26. })
  27. });
  28. export const CreateDateNotesDto = z.object({
  29. code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').openapi({
  30. description: '股票代码',
  31. example: '600000'
  32. }),
  33. noteDate: z.coerce.date<Date>('备注日期格式不正确').openapi({
  34. description: '备注日期',
  35. example: '2024-01-15T00:00:00Z'
  36. }),
  37. note: z.string().min(1, '备注内容不能为空').max(255, '备注内容最多255个字符').openapi({
  38. description: '备注内容',
  39. example: '重点关注该股票走势'
  40. })
  41. });
  42. export const UpdateDateNotesDto = z.object({
  43. code: z.string().min(1, '股票代码不能为空').max(255, '股票代码最多255个字符').optional().openapi({
  44. description: '股票代码',
  45. example: '600000'
  46. }),
  47. noteDate: z.coerce.date<Date>('备注日期格式不正确').optional().openapi({
  48. description: '备注日期',
  49. example: '2024-01-15T00:00:00Z'
  50. }),
  51. note: z.string().min(1, '备注内容不能为空').max(255, '备注内容最多255个字符').optional().openapi({
  52. description: '备注内容',
  53. example: '更新后的备注内容'
  54. })
  55. });