Files
2025-08-09 03:09:17 +09:00

46 lines
1.3 KiB
Dart

class Team {
final String id;
final String eventId;
final String name;
final List<String> memberIds;
final String? description;
final DateTime? createdAt;
final DateTime? updatedAt;
Team({
required this.id,
required this.eventId,
required this.name,
required this.memberIds,
this.description,
this.createdAt,
this.updatedAt,
});
// JSON 데이터로부터 Team 객체 생성
factory Team.fromJson(Map<String, dynamic> json) {
return Team(
id: json['id']?.toString() ?? '',
eventId: json['eventId']?.toString() ?? '',
name: json['name']?.toString() ?? '',
memberIds: json['memberIds'] != null ? List<String>.from(json['memberIds']) : [],
description: json['description']?.toString(),
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
);
}
// Team 객체를 JSON으로 변환
Map<String, dynamic> toJson() {
return {
'id': id,
'eventId': eventId,
'name': name,
'memberIds': memberIds,
'description': description,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
};
}
}