class OutingLogComment {
  final String id;
  final String logId;
  final String commenterId;
  final String commenterName;
  final String commenterPosition;
  final int ratingStars;
  final String commentText;
  final DateTime createTime;

  const OutingLogComment({
    required this.id,
    this.logId = '',
    this.commenterId = '',
    this.commenterName = '',
    this.commenterPosition = '',
    this.ratingStars = 5,
    required this.commentText,
    required this.createTime,
  });

  factory OutingLogComment.fromJson(Map<String, dynamic> json) {
    return OutingLogComment(
      id: json['id'] as String,
      logId: json['logId'] as String? ?? '',
      commenterId: json['commenterId'] as String? ?? '',
      commenterName: json['commenterName'] as String? ?? '',
      commenterPosition: json['commenterPosition'] as String? ?? '',
      ratingStars: json['ratingStars'] as int? ?? 5,
      commentText: json['commentText'] as String? ?? '',
      createTime: DateTime.parse(json['createTime'] as String),
    );
  }

  Map<String, dynamic> toJson() => {
    'id': id,
    'logId': logId,
    'commenterId': commenterId,
    'commenterName': commenterName,
    'commenterPosition': commenterPosition,
    'ratingStars': ratingStars,
    'commentText': commentText,
    'createTime': createTime.toIso8601String(),
  };
}
