Line data Source code
1 : class Team {
2 : final String id;
3 : final String eventId;
4 : final String name;
5 : final List<String> memberIds;
6 : final String? description;
7 : final DateTime? createdAt;
8 : final DateTime? updatedAt;
9 :
10 2 : Team({
11 : required this.id,
12 : required this.eventId,
13 : required this.name,
14 : required this.memberIds,
15 : this.description,
16 : this.createdAt,
17 : this.updatedAt,
18 : });
19 :
20 : // JSON 데이터로부터 Team 객체 생성
21 1 : factory Team.fromJson(Map<String, dynamic> json) {
22 1 : return Team(
23 2 : id: json['id']?.toString() ?? '',
24 2 : eventId: json['eventId']?.toString() ?? '',
25 2 : name: json['name']?.toString() ?? '',
26 3 : memberIds: json['memberIds'] != null ? List<String>.from(json['memberIds']) : [],
27 1 : description: json['description']?.toString(),
28 1 : createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
29 1 : updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
30 : );
31 : }
32 :
33 : // Team 객체를 JSON으로 변환
34 1 : Map<String, dynamic> toJson() {
35 1 : return {
36 1 : 'id': id,
37 1 : 'eventId': eventId,
38 1 : 'name': name,
39 1 : 'memberIds': memberIds,
40 1 : 'description': description,
41 1 : 'createdAt': createdAt?.toIso8601String(),
42 1 : 'updatedAt': updatedAt?.toIso8601String(),
43 : };
44 : }
45 : }
|