Line data Source code
1 : class Event {
2 : final String id;
3 : final String clubId;
4 : final String title;
5 : final String? description;
6 : final DateTime startDate;
7 : final DateTime? endDate;
8 : final String? location;
9 : final String? type;
10 : final String? status;
11 : final int? maxParticipants;
12 : final int? currentParticipants;
13 : final int? gameCount;
14 : final double? participantFee;
15 : final DateTime? registrationDeadline;
16 : final String? publicHash;
17 : final String? accessPassword;
18 : final bool isActive;
19 : final String? createdBy;
20 : final DateTime? createdAt;
21 : final DateTime? updatedAt;
22 :
23 8 : Event({
24 : required this.id,
25 : required this.clubId,
26 : required this.title,
27 : this.description,
28 : required this.startDate,
29 : this.endDate,
30 : this.location,
31 : this.type,
32 : this.status,
33 : this.maxParticipants,
34 : this.currentParticipants,
35 : this.gameCount,
36 : this.participantFee,
37 : this.registrationDeadline,
38 : this.publicHash,
39 : this.accessPassword,
40 : required this.isActive,
41 : this.createdBy,
42 : this.createdAt,
43 : this.updatedAt,
44 : });
45 :
46 : // JSON 데이터로부터 Event 객체 생성
47 4 : factory Event.fromJson(Map<String, dynamic> json) {
48 4 : return Event(
49 8 : id: json['id']?.toString() ?? '',
50 8 : clubId: json['clubId']?.toString() ?? '',
51 4 : title: json['title'] ?? '',
52 6 : description: json['description']?.toString(),
53 17 : startDate: json['startDate'] != null ? DateTime.parse(json['startDate'].toString()) : DateTime.now(),
54 10 : endDate: json['endDate'] != null ? DateTime.parse(json['endDate'].toString()) : null,
55 6 : location: json['location']?.toString(),
56 6 : type: json['type']?.toString(),
57 6 : status: json['status']?.toString(),
58 4 : maxParticipants: json['maxParticipants'],
59 4 : currentParticipants: json['currentParticipants'],
60 4 : gameCount: json['gameCount'],
61 7 : participantFee: json['participantFee'] != null ? double.tryParse(json['participantFee'].toString()) : null,
62 13 : registrationDeadline: json['registrationDeadline'] != null ? DateTime.parse(json['registrationDeadline'].toString()) : null,
63 5 : publicHash: json['publicHash']?.toString(),
64 5 : accessPassword: json['accessPassword']?.toString(),
65 4 : isActive: json['isActive'] ?? true,
66 5 : createdBy: json['createdBy']?.toString(),
67 7 : createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
68 7 : updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
69 : );
70 : }
71 :
72 : // Event 객체를 JSON으로 변환
73 2 : Map<String, dynamic> toJson() {
74 2 : return {
75 2 : 'id': id,
76 2 : 'clubId': clubId,
77 2 : 'title': title,
78 2 : 'description': description,
79 4 : 'startDate': startDate.toIso8601String(),
80 4 : 'endDate': endDate?.toIso8601String(),
81 2 : 'location': location,
82 2 : 'type': type,
83 2 : 'status': status,
84 2 : 'maxParticipants': maxParticipants,
85 2 : 'currentParticipants': currentParticipants,
86 2 : 'gameCount': gameCount,
87 2 : 'participantFee': participantFee,
88 4 : 'registrationDeadline': registrationDeadline?.toIso8601String(),
89 2 : 'publicHash': publicHash,
90 2 : 'accessPassword': accessPassword,
91 2 : 'isActive': isActive,
92 2 : 'createdBy': createdBy,
93 3 : 'createdAt': createdAt?.toIso8601String(),
94 3 : 'updatedAt': updatedAt?.toIso8601String(),
95 : };
96 : }
97 : }
|