class CommentEntity {
  final String authorId;
  final String destinationId;
  final String serviceId;
  final String content;
  final double score;
  final bool isFromUser;
  final String createdAt;

  const CommentEntity({
    required this.authorId,
    required this.destinationId,
    required this.serviceId,
    required this.content,
    required this.score,
    required this.isFromUser,
    required this.createdAt,
  });

  static CommentEntity fromDocument(Map<String, dynamic> doc) {
    return CommentEntity(
      authorId: doc['author_id'] as String? ?? '',
      destinationId: doc['destination_id'] as String? ?? '',
      serviceId: doc['service_id'] as String? ?? '',
      content: doc['content'] as String? ?? '',
      score: (doc['score'] as num?)?.toDouble() ?? 0.0,
      isFromUser: doc['is_from_user'] as bool? ?? false,
      createdAt: doc['created_at']?.toString() ?? '',
    );
  }

  Map<String, dynamic> toDocument() {
    return {
      'author_id': authorId,
      'destination_id': destinationId,
      'service_id': serviceId,
      'content': content,
      'score': score,
      'is_from_user': isFromUser,
      'created_at': createdAt,
    };
  }

  @override
  String toString() {
    return 'CommentEntity{authorId: $authorId, destinationId: $destinationId, score: $score}';
  }
}
