Parcourir la source

🐛 fix(stock): 修复日期备注模块日期解析问题

- 将CreateDateNotesDto中的noteDate字段从z.date()改为z.coerce.date(),支持字符串自动转换为日期
- 将UpdateDateNotesDto中的noteDate字段从z.date()改为z.coerce.date(),支持字符串自动转换为日期
- 解决前端传递字符串日期格式时的验证失败问题
yourname il y a 8 mois
Parent
commit
968cda6ad2
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      src/server/modules/stock/date-notes.entity.ts

+ 2 - 2
src/server/modules/stock/date-notes.entity.ts

@@ -34,12 +34,12 @@ export const DateNotesSchema = z.object({
 
 export const CreateDateNotesDto = z.object({
   code: z.string().max(255).openapi({ description: '股票代码', example: '001339' }),
-  noteDate: z.date().openapi({ description: '备注日期', example: '2024-11-07T08:00:00Z' }),
+  noteDate: z.coerce.date().openapi({ description: '备注日期', example: '2024-11-07T08:00:00Z' }),
   note: z.string().max(255).openapi({ description: '备注内容', example: 'test01' })
 });
 
 export const UpdateDateNotesDto = z.object({
   code: z.string().max(255).optional().openapi({ description: '股票代码', example: '001339' }),
-  noteDate: z.date().optional().openapi({ description: '备注日期', example: '2024-11-07T08:00:00Z' }),
+  noteDate: z.coerce.date().optional().openapi({ description: '备注日期', example: '2024-11-07T08:00:00Z' }),
   note: z.string().max(255).optional().openapi({ description: '备注内容', example: 'test01' })
 });