feat: implement base architecture and core repositories for weapon tracking and target analysis functionality
This commit is contained in:
57
lib/data/models/maintenance.dart
Normal file
57
lib/data/models/maintenance.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
enum MaintenanceType {
|
||||
cleaning('Nettoyage'),
|
||||
repair('Réparation'),
|
||||
inspection('Inspection'),
|
||||
upgrade('Amélioration'),
|
||||
other('Autre');
|
||||
|
||||
final String displayName;
|
||||
const MaintenanceType(this.displayName);
|
||||
|
||||
static MaintenanceType fromString(String value) {
|
||||
return MaintenanceType.values.firstWhere(
|
||||
(type) => type.name == value,
|
||||
orElse: () => MaintenanceType.other,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MaintenanceEntry {
|
||||
final String id;
|
||||
final String weaponId;
|
||||
final MaintenanceType type;
|
||||
final String description;
|
||||
final DateTime date;
|
||||
final int? roundsSinceLastMaintenance;
|
||||
|
||||
MaintenanceEntry({
|
||||
required this.id,
|
||||
required this.weaponId,
|
||||
required this.type,
|
||||
required this.description,
|
||||
required this.date,
|
||||
this.roundsSinceLastMaintenance,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'weapon_id': weaponId,
|
||||
'type': type.name,
|
||||
'description': description,
|
||||
'date': date.toIso8601String(),
|
||||
'rounds_since_last': roundsSinceLastMaintenance,
|
||||
};
|
||||
}
|
||||
|
||||
factory MaintenanceEntry.fromMap(Map<String, dynamic> map) {
|
||||
return MaintenanceEntry(
|
||||
id: map['id'] as String,
|
||||
weaponId: map['weapon_id'] as String,
|
||||
type: MaintenanceType.fromString(map['type'] as String),
|
||||
description: map['description'] as String,
|
||||
date: DateTime.parse(map['date'] as String),
|
||||
roundsSinceLastMaintenance: map['rounds_since_last'] as int?,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user