|
|
@@ -1,4 +1,5 @@
|
|
|
import { z } from '@hono/zod-openapi';
|
|
|
+import { UserSchema } from '@/server/modules/users/user.schema';
|
|
|
|
|
|
// 基础消息Schema
|
|
|
export const ChatMessageSchema = z.object({
|
|
|
@@ -18,10 +19,13 @@ export const ChatMessageSchema = z.object({
|
|
|
example: '这是一条文本消息',
|
|
|
description: '消息内容'
|
|
|
}),
|
|
|
- senderId: z.string().nullable().openapi({
|
|
|
- example: 'user_123',
|
|
|
+ senderId: z.number().int().positive().nullable().openapi({
|
|
|
+ example: 1,
|
|
|
description: '发送者ID'
|
|
|
}),
|
|
|
+ sender: UserSchema.omit({ password: true }).nullable().optional().openapi({
|
|
|
+ description: '发送者用户信息'
|
|
|
+ }),
|
|
|
senderName: z.string().nullable().openapi({
|
|
|
example: '张三',
|
|
|
description: '发送者名称'
|
|
|
@@ -75,8 +79,8 @@ export const CreateChatMessageDto = z.object({
|
|
|
example: '这是一条文本消息',
|
|
|
description: '消息内容'
|
|
|
}),
|
|
|
- senderId: z.string().nullable().optional().openapi({
|
|
|
- example: 'user_123',
|
|
|
+ senderId: z.coerce.number().int().positive().nullable().optional().openapi({
|
|
|
+ example: 1,
|
|
|
description: '发送者ID'
|
|
|
}),
|
|
|
senderName: z.string().nullable().optional().openapi({
|
|
|
@@ -107,8 +111,8 @@ export const UpdateChatMessageDto = z.object({
|
|
|
example: '这是一条文本消息',
|
|
|
description: '消息内容'
|
|
|
}),
|
|
|
- senderId: z.string().nullable().optional().openapi({
|
|
|
- example: 'user_123',
|
|
|
+ senderId: z.coerce.number().int().positive().nullable().optional().openapi({
|
|
|
+ example: 1,
|
|
|
description: '发送者ID'
|
|
|
}),
|
|
|
senderName: z.string().nullable().optional().openapi({
|