Line data Source code
1 : class Participant {
2 : final String id;
3 : final String eventId;
4 : final String memberId;
5 : final String? name;
6 : final String? email;
7 : final String? phoneNumber;
8 : final String? status; // 'registered', 'confirmed', 'cancelled', 'attended'
9 : final DateTime? registeredAt;
10 : final DateTime? confirmedAt;
11 : final DateTime? cancelledAt;
12 : final DateTime? attendedAt;
13 : final bool isPaid;
14 : final double? paidAmount;
15 : final String? notes;
16 : final DateTime? createdAt;
17 : final DateTime? updatedAt;
18 : String? memberType; // 회원 유형 필드 추가: '정회원', '준회원', '게스트' 등
19 :
20 5 : Participant({
21 : required this.id,
22 : required this.eventId,
23 : required this.memberId,
24 : this.name,
25 : this.email,
26 : this.phoneNumber,
27 : this.status,
28 : this.registeredAt,
29 : this.confirmedAt,
30 : this.cancelledAt,
31 : this.attendedAt,
32 : this.isPaid = false,
33 : this.paidAmount,
34 : this.notes,
35 : this.createdAt,
36 : this.updatedAt,
37 : });
38 :
39 : // JSON 데이터로부터 Participant 객체 생성
40 2 : factory Participant.fromJson(Map<String, dynamic> json) {
41 2 : return Participant(
42 4 : id: json['id']?.toString() ?? '',
43 4 : eventId: json['eventId']?.toString() ?? '',
44 4 : memberId: json['memberId']?.toString() ?? '',
45 4 : name: json['name']?.toString(),
46 2 : email: json['email']?.toString(),
47 2 : phoneNumber: json['phoneNumber']?.toString(),
48 3 : status: json['status']?.toString(),
49 2 : registeredAt: json['registeredAt'] != null ? DateTime.parse(json['registeredAt'].toString()) : null,
50 2 : confirmedAt: json['confirmedAt'] != null ? DateTime.parse(json['confirmedAt'].toString()) : null,
51 2 : cancelledAt: json['cancelledAt'] != null ? DateTime.parse(json['cancelledAt'].toString()) : null,
52 2 : attendedAt: json['attendedAt'] != null ? DateTime.parse(json['attendedAt'].toString()) : null,
53 2 : isPaid: json['isPaid'] ?? false,
54 2 : paidAmount: json['paidAmount'] != null ? double.tryParse(json['paidAmount'].toString()) : null,
55 2 : notes: json['notes']?.toString(),
56 2 : createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
57 2 : updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
58 : );
59 : }
60 :
61 : // Participant 객체를 JSON으로 변환
62 0 : Map<String, dynamic> toJson() {
63 0 : return {
64 0 : 'id': id,
65 0 : 'eventId': eventId,
66 0 : 'memberId': memberId,
67 0 : 'name': name,
68 0 : 'email': email,
69 0 : 'phoneNumber': phoneNumber,
70 0 : 'status': status,
71 0 : 'registeredAt': registeredAt?.toIso8601String(),
72 0 : 'confirmedAt': confirmedAt?.toIso8601String(),
73 0 : 'cancelledAt': cancelledAt?.toIso8601String(),
74 0 : 'attendedAt': attendedAt?.toIso8601String(),
75 0 : 'isPaid': isPaid,
76 0 : 'paidAmount': paidAmount,
77 0 : 'notes': notes,
78 0 : 'createdAt': createdAt?.toIso8601String(),
79 0 : 'updatedAt': updatedAt?.toIso8601String(),
80 : };
81 : }
82 : }
|