56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'device.freezed.dart';
|
|
part 'device.g.dart';
|
|
|
|
@freezed
|
|
abstract class DeviceType with _$DeviceType {
|
|
const factory DeviceType({
|
|
required int id,
|
|
required String brand,
|
|
required String productCode,
|
|
required String name,
|
|
@Default(true) bool isNetworkRequired,
|
|
@Default(true) bool isActive,
|
|
String? createdAt,
|
|
}) = _DeviceType;
|
|
|
|
factory DeviceType.fromJson(Map<String, dynamic> json) =>
|
|
_$DeviceTypeFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
abstract class DeviceInfo with _$DeviceInfo {
|
|
const factory DeviceInfo({
|
|
required int id,
|
|
required String sn,
|
|
DeviceType? deviceType,
|
|
DeviceType? deviceTypeInfo,
|
|
String? macAddress,
|
|
@Default('') String name,
|
|
@Default('in_stock') String status,
|
|
@Default('') String firmwareVersion,
|
|
String? lastOnlineAt,
|
|
String? createdAt,
|
|
}) = _DeviceInfo;
|
|
|
|
factory DeviceInfo.fromJson(Map<String, dynamic> json) =>
|
|
_$DeviceInfoFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
abstract class UserDevice with _$UserDevice {
|
|
const factory UserDevice({
|
|
required int id,
|
|
required DeviceInfo device,
|
|
int? spirit,
|
|
String? spiritName,
|
|
@Default('owner') String bindType,
|
|
String? bindTime,
|
|
@Default(true) bool isActive,
|
|
}) = _UserDevice;
|
|
|
|
factory UserDevice.fromJson(Map<String, dynamic> json) =>
|
|
_$UserDeviceFromJson(json);
|
|
}
|