第二次提交
This commit is contained in:
77
lib/features/devices/data/models/device_model.dart
Normal file
77
lib/features/devices/data/models/device_model.dart
Normal file
@@ -0,0 +1,77 @@
|
||||
import 'package:maibu_satabot_v2/core/data/base_model.dart';
|
||||
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
|
||||
|
||||
class DeviceModel extends DeviceEntity implements BaseModel {
|
||||
DeviceModel({
|
||||
required super.deviceName,
|
||||
required super.productId,
|
||||
required super.productName,
|
||||
required super.tenantId,
|
||||
required super.tenantName,
|
||||
required super.status,
|
||||
required super.activeTime,
|
||||
required super.deviceAlias,
|
||||
required super.isBind,
|
||||
required super.onlineStatus,
|
||||
});
|
||||
|
||||
factory DeviceModel.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceModel(
|
||||
deviceName: json['deviceName'],
|
||||
productId: json['productId'],
|
||||
productName: json['productName'],
|
||||
tenantId: json['tenantId'],
|
||||
tenantName: json['tenantName'],
|
||||
status: json['status'],
|
||||
activeTime: json['activeTime'],
|
||||
deviceAlias: json['deviceAlias'],
|
||||
isBind: json['isBind'],
|
||||
onlineStatus: json['onlineStatus'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'deviceName': deviceName,
|
||||
'productId': productId,
|
||||
'productName': productName,
|
||||
'tenantId': tenantId,
|
||||
'tenantName': tenantName,
|
||||
'status': status,
|
||||
'activeTime': activeTime,
|
||||
'deviceAlias': deviceAlias,
|
||||
'isBind': isBind,
|
||||
'onlineStatus': onlineStatus,
|
||||
};
|
||||
}
|
||||
|
||||
toEntity() {
|
||||
return DeviceEntity(
|
||||
deviceName: deviceName,
|
||||
productId: productId,
|
||||
productName: productName,
|
||||
tenantId: tenantId,
|
||||
tenantName: tenantName,
|
||||
status: status,
|
||||
activeTime: activeTime,
|
||||
deviceAlias: deviceAlias,
|
||||
isBind: isBind,
|
||||
onlineStatus: onlineStatus,
|
||||
);
|
||||
}
|
||||
|
||||
factory DeviceModel.fromEntity(DeviceEntity entity) {
|
||||
return DeviceModel(
|
||||
deviceName: entity.deviceName,
|
||||
productId: entity.productId,
|
||||
productName: entity.productName,
|
||||
tenantId: entity.tenantId,
|
||||
tenantName: entity.tenantName,
|
||||
status: entity.status,
|
||||
activeTime: entity.activeTime,
|
||||
deviceAlias: entity.deviceAlias,
|
||||
isBind: entity.isBind,
|
||||
onlineStatus: entity.onlineStatus,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user