74 lines
2.2 KiB
Dart
74 lines
2.2 KiB
Dart
class Event {
|
|
final String id;
|
|
final String clubId;
|
|
final String title;
|
|
final String? description;
|
|
final DateTime startDate;
|
|
final DateTime? endDate;
|
|
final String? location;
|
|
final String? type;
|
|
final int? maxParticipants;
|
|
final int? currentParticipants;
|
|
final bool isActive;
|
|
final String? createdBy;
|
|
final DateTime? createdAt;
|
|
final DateTime? updatedAt;
|
|
|
|
Event({
|
|
required this.id,
|
|
required this.clubId,
|
|
required this.title,
|
|
this.description,
|
|
required this.startDate,
|
|
this.endDate,
|
|
this.location,
|
|
this.type,
|
|
this.maxParticipants,
|
|
this.currentParticipants,
|
|
required this.isActive,
|
|
this.createdBy,
|
|
this.createdAt,
|
|
this.updatedAt,
|
|
});
|
|
|
|
// JSON 데이터로부터 Event 객체 생성
|
|
factory Event.fromJson(Map<String, dynamic> json) {
|
|
return Event(
|
|
id: json['id']?.toString() ?? '',
|
|
clubId: json['clubId']?.toString() ?? '',
|
|
title: json['title'] ?? '',
|
|
description: json['description']?.toString(),
|
|
startDate: json['startDate'] != null ? DateTime.parse(json['startDate'].toString()) : DateTime.now(),
|
|
endDate: json['endDate'] != null ? DateTime.parse(json['endDate'].toString()) : null,
|
|
location: json['location']?.toString(),
|
|
type: json['type']?.toString(),
|
|
maxParticipants: json['maxParticipants'],
|
|
currentParticipants: json['currentParticipants'],
|
|
isActive: json['isActive'] ?? true,
|
|
createdBy: json['createdBy']?.toString(),
|
|
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
|
|
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
|
|
);
|
|
}
|
|
|
|
// Event 객체를 JSON으로 변환
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'clubId': clubId,
|
|
'title': title,
|
|
'description': description,
|
|
'startDate': startDate.toIso8601String(),
|
|
'endDate': endDate?.toIso8601String(),
|
|
'location': location,
|
|
'type': type,
|
|
'maxParticipants': maxParticipants,
|
|
'currentParticipants': currentParticipants,
|
|
'isActive': isActive,
|
|
'createdBy': createdBy,
|
|
'createdAt': createdAt?.toIso8601String(),
|
|
'updatedAt': updatedAt?.toIso8601String(),
|
|
};
|
|
}
|
|
}
|