75 lines
2.0 KiB
Dart
75 lines
2.0 KiB
Dart
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
class ProjectModel {
|
|
final String id;
|
|
final String name;
|
|
final String gitUrl;
|
|
final String? apiDocUrl;
|
|
final String description;
|
|
final List<String> flavors;
|
|
final DateTime createdAt;
|
|
|
|
// Dynamic enrichment fields (populated from logs)
|
|
final DateTime? lastUpdateDate;
|
|
final String? lastWorkedBy;
|
|
|
|
ProjectModel({
|
|
required this.id,
|
|
required this.name,
|
|
required this.gitUrl,
|
|
this.apiDocUrl,
|
|
required this.description,
|
|
required this.flavors,
|
|
required this.createdAt,
|
|
this.lastUpdateDate,
|
|
this.lastWorkedBy,
|
|
});
|
|
|
|
factory ProjectModel.fromMap(String id, Map<String, dynamic> data) {
|
|
return ProjectModel(
|
|
id: id,
|
|
name: data['name'] ?? '',
|
|
gitUrl: data['gitUrl'] ?? '',
|
|
apiDocUrl: data['apiDocUrl'],
|
|
description: data['description'] ?? '',
|
|
flavors: List<String>.from(data['flavors'] ?? []),
|
|
createdAt: (data['createdAt'] is Timestamp)
|
|
? (data['createdAt'] as Timestamp).toDate()
|
|
: DateTime.now(),
|
|
lastUpdateDate: (data['lastUpdateDate'] is Timestamp)
|
|
? (data['lastUpdateDate'] as Timestamp).toDate()
|
|
: null,
|
|
lastWorkedBy: data['lastWorkedBy'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'gitUrl': gitUrl,
|
|
'apiDocUrl': apiDocUrl,
|
|
'description': description,
|
|
'flavors': flavors,
|
|
'createdAt': Timestamp.fromDate(createdAt),
|
|
// Note: lastUpdateDate and lastWorkedBy typically managed through app logic/logs
|
|
};
|
|
}
|
|
|
|
ProjectModel copyWith({
|
|
DateTime? lastUpdateDate,
|
|
String? lastWorkedBy,
|
|
}) {
|
|
return ProjectModel(
|
|
id: id,
|
|
name: name,
|
|
gitUrl: gitUrl,
|
|
apiDocUrl: apiDocUrl,
|
|
description: description,
|
|
flavors: flavors,
|
|
createdAt: createdAt,
|
|
lastUpdateDate: lastUpdateDate ?? this.lastUpdateDate,
|
|
lastWorkedBy: lastWorkedBy ?? this.lastWorkedBy,
|
|
);
|
|
}
|
|
}
|