61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
/// Project Progress Model
|
|
///
|
|
/// Data model for project progress from API responses with Hive caching.
|
|
/// Based on API response from frappe.client.get_list with doctype "Progress of construction"
|
|
library;
|
|
|
|
import 'package:hive_ce/hive.dart';
|
|
import 'package:worker/core/constants/storage_constants.dart';
|
|
import 'package:worker/features/projects/domain/entities/project_progress.dart';
|
|
|
|
part 'project_progress_model.g.dart';
|
|
|
|
/// Project Progress Model - Type ID: 64
|
|
@HiveType(typeId: HiveTypeIds.projectProgressModel)
|
|
class ProjectProgressModel extends HiveObject {
|
|
/// Unique identifier (API: name)
|
|
@HiveField(0)
|
|
final String id;
|
|
|
|
/// Progress status label in Vietnamese (API: status)
|
|
@HiveField(1)
|
|
final String status;
|
|
|
|
ProjectProgressModel({
|
|
required this.id,
|
|
required this.status,
|
|
});
|
|
|
|
/// Create from JSON (API response)
|
|
factory ProjectProgressModel.fromJson(Map<String, dynamic> json) {
|
|
return ProjectProgressModel(
|
|
id: json['name'] as String,
|
|
status: json['status'] as String,
|
|
);
|
|
}
|
|
|
|
/// Convert to JSON
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'name': id,
|
|
'status': status,
|
|
};
|
|
}
|
|
|
|
/// Convert to entity
|
|
ProjectProgress toEntity() {
|
|
return ProjectProgress(
|
|
id: id,
|
|
status: status,
|
|
);
|
|
}
|
|
|
|
/// Create from entity
|
|
factory ProjectProgressModel.fromEntity(ProjectProgress entity) {
|
|
return ProjectProgressModel(
|
|
id: entity.id,
|
|
status: entity.status,
|
|
);
|
|
}
|
|
}
|