app-starlock/lib/main/lockMian/entity/lockListInfo_entity.dart

568 lines
16 KiB
Dart
Raw Normal View History

import 'dart:convert';
2023-11-01 17:28:59 +08:00
class LockListInfoEntity {
LockListInfoEntity(
{this.errorCode, this.description, this.errorMsg, this.data});
LockListInfoEntity.fromJson(Map<String, dynamic> json) {
errorCode = json['errorCode'];
description = json['description'];
errorMsg = json['errorMsg'];
data = json['data'] != null
? LockListInfoGroupEntity.fromJson(json['data'])
: null;
2023-11-01 17:28:59 +08:00
}
int? errorCode;
String? description;
String? errorMsg;
LockListInfoGroupEntity? data;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['errorCode'] = errorCode;
data['description'] = description;
data['errorMsg'] = errorMsg;
if (this.data != null) {
data['data'] = this.data!.toJson();
}
return data;
}
}
class LockListInfoGroupEntity {
LockListInfoGroupEntity(
{this.groupList, this.pageNo, this.pageSize, this.pages, this.total});
2023-11-01 17:28:59 +08:00
LockListInfoGroupEntity.fromJson(Map<String, dynamic> json) {
if (json['groupList'] != null) {
groupList = <GroupList>[];
json['groupList'].forEach((v) {
groupList!.add(GroupList.fromJson(v));
});
}
pageNo = json['pageNo'];
pageSize = json['pageSize'];
pages = json['pages'];
total = json['total'];
}
List<GroupList>? groupList;
int? pageNo;
int? pageSize;
int? pages;
int? total;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (groupList != null) {
data['groupList'] = groupList!.map((v) => v.toJson()).toList();
}
data['pageNo'] = pageNo;
data['pageSize'] = pageSize;
data['pages'] = pages;
data['total'] = total;
return data;
}
}
class GroupList {
GroupList({this.groupName, this.groupId, this.lockList});
GroupList.fromJson(Map<String, dynamic> json) {
groupName = json['groupName'];
groupId = json['groupId'];
if (json['lockList'] != null) {
lockList = <LockListInfoItemEntity>[];
json['lockList'].forEach((v) {
lockList!.add(LockListInfoItemEntity.fromJson(v));
});
}
}
String? groupName;
int? groupId;
List<LockListInfoItemEntity>? lockList;
bool _isChecked = false;
bool get isChecked => _isChecked ?? false;
set isChecked(bool value) => _isChecked = value;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['groupName'] = groupName;
data['groupId'] = groupId;
if (lockList != null) {
data['lockList'] = lockList!.map((v) => v.toJson()).toList();
}
return data;
}
GroupList copy() {
return GroupList(
groupName: groupName,
groupId: groupId,
lockList: lockList?.map((e) => e.copy()).toList(),
);
}
2023-11-01 17:28:59 +08:00
}
class LockListInfoItemEntity {
2024-05-27 17:38:23 +08:00
LockListInfoItemEntity({
this.keyId,
this.lockId,
this.lockName,
this.lockAlias,
this.electricQuantity,
this.fwVersion,
this.hwVersion,
this.keyType,
this.passageMode,
this.userType,
this.startDate,
this.endDate,
this.weekDays,
this.remoteEnable,
this.faceAuthentication,
this.lastFaceValidateTime,
this.nextFaceValidateTime,
this.keyRight,
this.keyStatus,
this.isLockOwner,
this.bluetooth,
this.lockFeature,
this.lockSetting,
this.sendDate,
this.lockUserNo,
this.electricQuantityDate,
this.electricQuantityStandby,
this.senderUserId,
this.isOnlyManageSelf,
this.restoreCount,
this.model,
this.vendor,
this.hasGateway,
this.appUnlockOnline,
2024-05-27 17:38:23 +08:00
this.mac,
this.initUserNo,
this.updateDate,
this.network,
2024-05-27 17:38:23 +08:00
});
2023-11-01 17:28:59 +08:00
LockListInfoItemEntity.fromJson(Map<String, dynamic> json) {
keyId = json['keyId'];
lockId = json['lockId'];
lockName = json['lockName'];
lockAlias = json['lockAlias'];
electricQuantity = json['electricQuantity'];
fwVersion = json['fwVersion'];
hwVersion = json['hwVersion'];
keyType = json['keyType'];
passageMode = json['passageMode'];
userType = json['userType'];
startDate = json['startDate'];
endDate = json['endDate'];
weekDays = json['weekDays'];
remoteEnable = json['remoteEnable'];
faceAuthentication = json['faceAuthentication'];
lastFaceValidateTime = json['lastFaceValidateTime'];
nextFaceValidateTime = json['nextFaceValidateTime'];
2023-11-01 17:28:59 +08:00
keyRight = json['keyRight'];
keyStatus = json['keyStatus'];
isLockOwner = json['isLockOwner'];
sendDate = json['sendDate'];
2023-12-16 11:20:36 +08:00
lockUserNo = json['lockUserNo'];
senderUserId = json['senderUserId'];
electricQuantityDate = json['electricQuantityDate'];
electricQuantityStandby = json['electricQuantityStandby'];
isOnlyManageSelf = json['isOnlyManageSelf'];
restoreCount = json['restoreCount'];
model = json['model'];
vendor = json['vendor'];
2023-11-01 17:28:59 +08:00
bluetooth = json['bluetooth'] != null
? Bluetooth.fromJson(json['bluetooth'])
: null;
lockFeature = json['lockFeature'] != null
? LockFeature.fromJson(json['lockFeature'])
: null;
lockSetting = json['lockSetting'] != null
? LockSetting.fromJson(json['lockSetting'])
: null;
hasGateway = json['hasGateway'];
appUnlockOnline = json['appUnlockOnline'];
2024-05-27 17:38:23 +08:00
mac = json['mac'];
initUserNo = json['initUserNo'];
updateDate = json['updateDate'];
network =
json['network'] != null ? NetworkInfo.fromJson(json['network']) : null;
2023-11-01 17:28:59 +08:00
}
int? keyId;
int? lockId;
String? lockName;
String? lockAlias;
int? electricQuantity;
String? fwVersion;
String? hwVersion;
int? keyType;
int? passageMode;
int? userType;
int? startDate;
int? endDate;
List? weekDays;
int? remoteEnable;
int? faceAuthentication; //是否实名认证0-未知1-是2-否
int? lastFaceValidateTime;
int? nextFaceValidateTime; //下次人脸认证时间
int? keyRight;
int? keyStatus;
int? isLockOwner;
int? sendDate;
int? lockUserNo;
int? senderUserId;
int? electricQuantityDate;
int? electricQuantityStandby;
int? isOnlyManageSelf;
int? restoreCount;
String? model;
String? vendor;
Bluetooth? bluetooth;
LockFeature? lockFeature;
LockSetting? lockSetting;
int? hasGateway;
int? appUnlockOnline;
String? mac;
int? initUserNo;
int? updateDate;
NetworkInfo? network;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['keyId'] = keyId;
data['lockId'] = lockId;
data['lockName'] = lockName;
data['lockAlias'] = lockAlias;
data['electricQuantity'] = electricQuantity;
data['fwVersion'] = fwVersion;
data['hwVersion'] = hwVersion;
data['keyType'] = keyType;
data['passageMode'] = passageMode;
data['userType'] = userType;
data['startDate'] = startDate;
data['endDate'] = endDate;
data['weekDays'] = weekDays;
data['remoteEnable'] = remoteEnable;
data['faceAuthentication'] = faceAuthentication;
data['lastFaceValidateTime'] = lastFaceValidateTime;
data['nextFaceValidateTime'] = nextFaceValidateTime;
2023-11-01 17:28:59 +08:00
data['keyRight'] = keyRight;
data['keyStatus'] = keyStatus;
data['isLockOwner'] = isLockOwner;
data['sendDate'] = sendDate;
2023-12-16 11:20:36 +08:00
data['lockUserNo'] = lockUserNo;
data['senderUserId'] = senderUserId;
data['electricQuantityDate'] = electricQuantityDate;
data['electricQuantityStandby'] = electricQuantityStandby;
data['isOnlyManageSelf'] = isOnlyManageSelf;
data['restoreCount'] = restoreCount;
data['model'] = model;
data['vendor'] = vendor;
2023-11-01 17:28:59 +08:00
if (bluetooth != null) {
data['bluetooth'] = bluetooth!.toJson();
}
if (lockFeature != null) {
data['lockFeature'] = lockFeature!.toJson();
}
if (lockSetting != null) {
data['lockSetting'] = lockSetting!.toJson();
}
data['hasGateway'] = hasGateway;
data['appUnlockOnline'] = appUnlockOnline;
2024-05-27 17:38:23 +08:00
data['mac'] = mac;
data['initUserNo'] = initUserNo;
data['updateDate'] = updateDate;
if (network != null) {
data['network'] = network!.toJson();
}
2023-11-01 17:28:59 +08:00
return data;
}
//是否是锁拥有者 也代表是超级管理员
2024-05-27 17:38:23 +08:00
bool isLockOwnerBool() {
return isLockOwner == 1;
}
LockListInfoItemEntity copy() {
return LockListInfoItemEntity.fromJson(toJson());
}
2023-11-01 17:28:59 +08:00
}
class NetworkInfo {
NetworkInfo({
this.peerId,
this.isOnline,
this.wifiName,
});
NetworkInfo.fromJson(Map<String, dynamic> json) {
peerId = json['peerId'];
isOnline = json['isOnline'];
wifiName = json['wifiName'];
}
String? peerId;
String? wifiName;
int? isOnline;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['peerId'] = peerId;
data['wifiName'] = wifiName;
data['isOnline'] = isOnline;
return data;
}
}
2023-11-01 17:28:59 +08:00
class Bluetooth {
Bluetooth(
{this.bluetoothDeviceId,
this.bluetoothDeviceName,
this.publicKey,
this.privateKey,
this.signKey});
2023-11-01 17:28:59 +08:00
Bluetooth.fromJson(Map<String, dynamic> json) {
bluetoothDeviceId = json['bluetoothDeviceId'];
bluetoothDeviceName = json['bluetoothDeviceName'];
publicKey = json['publicKey'].cast<int>();
privateKey = json['privateKey'].cast<int>();
signKey = json['signKey'].cast<int>();
}
String? bluetoothDeviceId;
String? bluetoothDeviceName;
List<int>? publicKey;
List<int>? privateKey;
List<int>? signKey;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['bluetoothDeviceId'] = bluetoothDeviceId;
data['bluetoothDeviceName'] = bluetoothDeviceName;
data['publicKey'] = publicKey;
data['privateKey'] = privateKey;
data['signKey'] = signKey;
return data;
}
}
class LockFeature {
2024-05-27 17:38:23 +08:00
LockFeature({
this.password,
this.icCard,
this.fingerprint,
this.fingerVein,
this.palmVein,
this.isSupportIris,
this.d3Face,
this.bluetoothRemoteControl,
this.videoIntercom,
this.isSupportCatEye,
this.isSupportBackupBattery,
this.isNoSupportedBlueBroadcast,
this.wifiLockType,
this.wifi,
2024-05-27 17:38:23 +08:00
});
2023-11-01 17:28:59 +08:00
LockFeature.fromJson(Map<String, dynamic> json) {
password = json['password'];
icCard = json['icCard'];
fingerprint = json['fingerprint'];
fingerVein = json['fingerVein'];
palmVein = json['palmVein'];
isSupportIris = json['isSupportIris'];
2023-11-01 17:28:59 +08:00
d3Face = json['d3Face'];
bluetoothRemoteControl = json['bluetoothRemoteControl'];
videoIntercom = json['videoIntercom'];
2024-04-30 14:46:06 +08:00
isSupportCatEye = json['isSupportCatEye'];
2024-04-30 16:16:06 +08:00
isSupportBackupBattery = json['isSupportBackupBattery'];
isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast'];
wifiLockType = json['wifiLockType'];
wifi = json['wifi'];
2023-11-01 17:28:59 +08:00
}
int? password;
int? icCard;
int? fingerprint;
int? fingerVein;
int? palmVein;
int? isSupportIris;
int? d3Face;
int? bluetoothRemoteControl;
int? videoIntercom;
int? isSupportCatEye;
int? isSupportBackupBattery;
int? isNoSupportedBlueBroadcast;
int? wifiLockType;
int? wifi;
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['password'] = password;
data['icCard'] = icCard;
data['fingerprint'] = fingerprint;
data['fingerVein'] = fingerVein;
data['palmVein'] = palmVein;
data['isSupportIris'] = isSupportIris;
2023-11-01 17:28:59 +08:00
data['d3Face'] = d3Face;
data['bluetoothRemoteControl'] = bluetoothRemoteControl;
data['videoIntercom'] = videoIntercom;
2024-04-30 14:46:06 +08:00
data['isSupportCatEye'] = isSupportCatEye;
2024-04-30 16:16:06 +08:00
data['isSupportBackupBattery'] = isSupportBackupBattery;
data['isNoSupportedBlueBroadcast'] = isNoSupportedBlueBroadcast;
data['wifiLockType'] = wifiLockType;
data['wifi'] = wifi;
2023-11-01 17:28:59 +08:00
return data;
}
}
class LockSetting {
2024-01-23 18:37:03 +08:00
LockSetting({
this.attendance,
this.appUnlockOnline,
this.remoteUnlock,
this.catEyeConfig,
2024-01-23 18:37:03 +08:00
});
2023-11-01 17:28:59 +08:00
// 从 JSON 数据构造对象
factory LockSetting.fromJson(Map<String, dynamic> json) {
return LockSetting(
attendance: json['attendance']?.toInt(),
appUnlockOnline: json['appUnlockOnline']?.toInt(),
remoteUnlock: json['remoteUnlock']?.toInt(),
// 解析 catEyeConfig 字段
catEyeConfig: json['catEyeConfig'] != null
? (json['catEyeConfig'] as List)
.map((item) => CatEyeConfig.fromJson(item))
.toList()
: [],
);
2023-11-01 17:28:59 +08:00
}
int? attendance;
int? appUnlockOnline;
int? remoteUnlock;
List<CatEyeConfig>? catEyeConfig;
2023-11-01 17:28:59 +08:00
// 将对象转换为 JSON 数据
2023-11-01 17:28:59 +08:00
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['attendance'] = attendance;
data['appUnlockOnline'] = appUnlockOnline;
2024-01-23 18:37:03 +08:00
data['remoteUnlock'] = remoteUnlock;
if (catEyeConfig != null) {
data['catEyeConfig'] =
catEyeConfig!.map((v) => v.toJson()).toList(); // 序列化为 List
}
2023-11-01 17:28:59 +08:00
return data;
}
}
// 定义 CatEyeConfig 类
class CatEyeConfig {
CatEyeConfig({
required this.catEyeMode,
required this.catEyeModeConfig,
});
// 从 JSON 数据构造对象
factory CatEyeConfig.fromJson(Map<String, dynamic> json) {
return CatEyeConfig(
catEyeMode: json['catEyeMode']?.toInt() ?? 0,
catEyeModeConfig:
CatEyeModeConfig.fromJson(json['catEyeModeConfig'] ?? {}),
);
}
int catEyeMode;
CatEyeModeConfig catEyeModeConfig;
// 将对象转换为 JSON 数据
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['catEyeMode'] = catEyeMode;
data['catEyeModeConfig'] = catEyeModeConfig.toJson();
return data;
}
}
// 定义 CatEyeModeConfig 类
class CatEyeModeConfig {
// 构造函数
CatEyeModeConfig({
this.recordMode,
this.recordTime,
this.realTimeMode,
this.recordEndTime,
this.recordStartTime,
this.detectionDistance,
});
// 工厂方法:从 JSON 数据构造对象
factory CatEyeModeConfig.fromJson(Map<String, dynamic>? json) {
if (json == null) return CatEyeModeConfig();
return CatEyeModeConfig(
recordMode: _safeParseInt(json['recordMode']),
recordTime: json['recordTime']?.toString(),
realTimeMode: _safeParseInt(json['realTimeMode']),
recordEndTime: _safeParseInt(json['recordEndTime']),
recordStartTime: _safeParseInt(json['recordStartTime']),
detectionDistance: json['detectionDistance']?.toString(),
);
}
// 将对象转换为 JSON 数据
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['recordMode'] = recordMode;
data['recordTime'] = recordTime;
data['realTimeMode'] = realTimeMode;
data['recordEndTime'] = recordEndTime;
data['recordStartTime'] = recordStartTime;
data['detectionDistance'] = detectionDistance;
return data;
}
// 属性定义
int? recordMode; // 录制模式
String? recordTime; // 录制时间
int? realTimeMode; // 实时模式
int? recordEndTime; // 录制结束时间
int? recordStartTime; // 录制开始时间
String? detectionDistance; // 检测距离
// 辅助方法:安全地将字符串解析为整数
static int? _safeParseInt(dynamic value) {
if (value == null) return null;
if (value is int) return value; // 如果已经是 int直接返回
if (value is String) return int.tryParse(value); // 尝试解析字符串为整数
return null; // 如果无法解析,返回 null
}
@override
String toString() {
return 'CatEyeModeConfig{'
'recordMode: $recordMode, '
'recordTime: $recordTime, '
'realTimeMode: $realTimeMode, '
'recordEndTime: $recordEndTime, '
'recordStartTime: $recordStartTime, '
'detectionDistance: $detectionDistance}';
}
}