Files
smartgarden_chat/lib/models/chat_message.dart

33 lines
854 B
Dart

class ChatMessage {
final String text;
final bool isUser;
final DateTime timestamp;
final int? emotionCategory; // ← 새로 추가 (봇 메시지의 감정)
ChatMessage({
required this.text,
required this.isUser,
required this.timestamp,
this.emotionCategory,
});
// JSON에서 ChatMessage로 변환
factory ChatMessage.fromJson(Map<String, dynamic> json) {
return ChatMessage(
text: json['text'] as String,
isUser: json['isUser'] as bool,
timestamp: DateTime.parse(json['timestamp'] as String),
emotionCategory: json['emotionCategory'] as int?,
);
}
// ChatMessage를 JSON으로 변환
Map<String, dynamic> toJson() {
return {
'text': text,
'isUser': isUser,
'timestamp': timestamp.toIso8601String(),
'emotionCategory': emotionCategory,
};
}
}