所有一级页面和不分二级页面
This commit is contained in:
68
lib/features/v2/report/data/models/report_model.dart
Normal file
68
lib/features/v2/report/data/models/report_model.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import '../../domain/entities/report_entity.dart';
|
||||
|
||||
/// 上报数据模型
|
||||
class ReportModel {
|
||||
final String? location;
|
||||
final String? reportType;
|
||||
final String? deviceId;
|
||||
final String? description;
|
||||
final List<String>? mediaUrls;
|
||||
final String? problemLevel;
|
||||
|
||||
ReportModel({
|
||||
this.location,
|
||||
this.reportType,
|
||||
this.deviceId,
|
||||
this.description,
|
||||
this.mediaUrls,
|
||||
this.problemLevel,
|
||||
});
|
||||
|
||||
/// 从 JSON 创建
|
||||
factory ReportModel.fromJson(Map<String, dynamic> json) {
|
||||
return ReportModel(
|
||||
location: json['location'] as String?,
|
||||
reportType: json['reportType'] as String?,
|
||||
deviceId: json['deviceId'] as String?,
|
||||
description: json['description'] as String?,
|
||||
mediaUrls: (json['mediaUrls'] as List<dynamic>?)?.cast<String>(),
|
||||
problemLevel: json['problemLevel'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
/// 转换为 JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'location': location,
|
||||
'reportType': reportType,
|
||||
'deviceId': deviceId,
|
||||
'description': description,
|
||||
'mediaUrls': mediaUrls,
|
||||
'problemLevel': problemLevel,
|
||||
};
|
||||
}
|
||||
|
||||
/// 转换为实体
|
||||
ReportEntity toEntity() {
|
||||
return ReportEntity(
|
||||
location: location,
|
||||
reportType: reportType,
|
||||
deviceId: deviceId,
|
||||
description: description,
|
||||
mediaUrls: mediaUrls,
|
||||
problemLevel: problemLevel,
|
||||
);
|
||||
}
|
||||
|
||||
/// 从实体创建
|
||||
factory ReportModel.fromEntity(ReportEntity entity) {
|
||||
return ReportModel(
|
||||
location: entity.location,
|
||||
reportType: entity.reportType,
|
||||
deviceId: entity.deviceId,
|
||||
description: entity.description,
|
||||
mediaUrls: entity.mediaUrls,
|
||||
problemLevel: entity.problemLevel,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user