34 lines
741 B
Dart
34 lines
741 B
Dart
class Announcement {
|
|
final String id;
|
|
final String title;
|
|
final String content;
|
|
final DateTime createdAt;
|
|
final String? targetRole;
|
|
|
|
Announcement({
|
|
required this.id,
|
|
required this.title,
|
|
required this.content,
|
|
required this.createdAt,
|
|
this.targetRole,
|
|
});
|
|
|
|
factory Announcement.fromMap(Map<String, dynamic> map) {
|
|
return Announcement(
|
|
id: map['id'] ?? '',
|
|
title: map['title'] ?? '',
|
|
content: map['content'] ?? '',
|
|
createdAt: DateTime.tryParse(map['created_at'] ?? '') ?? DateTime.now(),
|
|
targetRole: map['target_role'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'title': title,
|
|
'content': content,
|
|
'target_role': targetRole,
|
|
};
|
|
}
|
|
}
|