refactor(data): move dto and schemas out of services directory

This commit is contained in:
2026-06-09 17:11:11 +08:00
parent 372b93fe45
commit 50940961ec
88 changed files with 279 additions and 356 deletions
+33
View File
@@ -0,0 +1,33 @@
/**
* 聊天历史中的单条消息 DTO
*/
import {
ChatMessageSchema,
type ChatMessageInput,
type ChatMessageData,
} from "@/data/schemas/chat/chat_message";
export class ChatMessage {
declare readonly role: string;
declare readonly content: string;
declare readonly id: string;
declare readonly createdAt: string;
private constructor(input: ChatMessageInput) {
const data = ChatMessageSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: ChatMessageInput): ChatMessage {
return new ChatMessage(input);
}
static fromJson(json: unknown): ChatMessage {
return ChatMessage.from(json as ChatMessageInput);
}
toJson(): ChatMessageData {
return ChatMessageSchema.parse(this);
}
}