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

609 lines
18 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:convert';
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;
}
int? errorCode;
String? description;
String? errorMsg;
LockListInfoGroupEntity? data;
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});
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;
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;
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(),
);
}
}
class LockListInfoItemEntity {
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,
this.mac,
this.initUserNo,
this.updateDate,
this.network,
});
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'];
keyRight = json['keyRight'];
keyStatus = json['keyStatus'];
isLockOwner = json['isLockOwner'];
sendDate = json['sendDate'];
lockUserNo = json['lockUserNo'];
senderUserId = json['senderUserId'];
electricQuantityDate = json['electricQuantityDate'];
electricQuantityStandby = json['electricQuantityStandby'];
isOnlyManageSelf = json['isOnlyManageSelf'];
restoreCount = json['restoreCount'];
model = json['model'];
vendor = json['vendor'];
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'];
mac = json['mac'];
initUserNo = json['initUserNo'];
updateDate = json['updateDate'];
network =
json['network'] != null ? NetworkInfo.fromJson(json['network']) : null;
}
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;
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;
data['keyRight'] = keyRight;
data['keyStatus'] = keyStatus;
data['isLockOwner'] = isLockOwner;
data['sendDate'] = sendDate;
data['lockUserNo'] = lockUserNo;
data['senderUserId'] = senderUserId;
data['electricQuantityDate'] = electricQuantityDate;
data['electricQuantityStandby'] = electricQuantityStandby;
data['isOnlyManageSelf'] = isOnlyManageSelf;
data['restoreCount'] = restoreCount;
data['model'] = model;
data['vendor'] = vendor;
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;
data['mac'] = mac;
data['initUserNo'] = initUserNo;
data['updateDate'] = updateDate;
if (network != null) {
data['network'] = network!.toJson();
}
return data;
}
//是否是锁拥有者 也代表是超级管理员
bool isLockOwnerBool() {
return isLockOwner == 1;
}
LockListInfoItemEntity copy() {
return LockListInfoItemEntity.fromJson(toJson());
}
@override
String toString() {
return 'LockListInfoItemEntity{keyId: $keyId, lockId: $lockId, lockName: $lockName, lockAlias: $lockAlias, electricQuantity: $electricQuantity, fwVersion: $fwVersion, hwVersion: $hwVersion, keyType: $keyType, passageMode: $passageMode, userType: $userType, startDate: $startDate, endDate: $endDate, weekDays: $weekDays, remoteEnable: $remoteEnable, faceAuthentication: $faceAuthentication, lastFaceValidateTime: $lastFaceValidateTime, nextFaceValidateTime: $nextFaceValidateTime, keyRight: $keyRight, keyStatus: $keyStatus, isLockOwner: $isLockOwner, sendDate: $sendDate, lockUserNo: $lockUserNo, senderUserId: $senderUserId, electricQuantityDate: $electricQuantityDate, electricQuantityStandby: $electricQuantityStandby, isOnlyManageSelf: $isOnlyManageSelf, restoreCount: $restoreCount, model: $model, vendor: $vendor, bluetooth: $bluetooth, lockFeature: $lockFeature, lockSetting: $lockSetting, hasGateway: $hasGateway, appUnlockOnline: $appUnlockOnline, mac: $mac, initUserNo: $initUserNo, updateDate: $updateDate, network: $network}';
}
}
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;
}
@override
String toString() {
return 'NetworkInfo{peerId: $peerId, wifiName: $wifiName, isOnline: $isOnline}';
}
}
class Bluetooth {
Bluetooth(
{this.bluetoothDeviceId,
this.bluetoothDeviceName,
this.publicKey,
this.privateKey,
this.signKey});
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;
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;
}
@override
String toString() {
return 'Bluetooth{bluetoothDeviceId: $bluetoothDeviceId, bluetoothDeviceName: $bluetoothDeviceName, publicKey: $publicKey, privateKey: $privateKey, signKey: $signKey}';
}
}
class LockFeature {
LockFeature({
this.password,
this.passwordIssue,
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,
this.isH264,
this.isH265,
this.isMJpeg,
});
LockFeature.fromJson(Map<String, dynamic> json) {
password = json['password'];
passwordIssue = json['passwordIssue'];
icCard = json['icCard'];
fingerprint = json['fingerprint'];
fingerVein = json['fingerVein'];
palmVein = json['palmVein'];
isSupportIris = json['isSupportIris'];
d3Face = json['d3Face'];
bluetoothRemoteControl = json['bluetoothRemoteControl'];
videoIntercom = json['videoIntercom'];
isSupportCatEye = json['isSupportCatEye'];
isSupportBackupBattery = json['isSupportBackupBattery'];
isNoSupportedBlueBroadcast = json['isNoSupportedBlueBroadcast'];
wifiLockType = json['wifiLockType'];
wifi = json['wifi'];
isH264 = json['isH264'];
isH265 = json['isH265'];
isMJpeg = json['isMJpeg'];
}
int? password;
int? passwordIssue;
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;
int? isH264;
int? isH265;
int? isMJpeg;
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['password'] = password;
data['passwordIssue'] = passwordIssue;
data['icCard'] = icCard;
data['fingerprint'] = fingerprint;
data['fingerVein'] = fingerVein;
data['palmVein'] = palmVein;
data['isSupportIris'] = isSupportIris;
data['d3Face'] = d3Face;
data['bluetoothRemoteControl'] = bluetoothRemoteControl;
data['videoIntercom'] = videoIntercom;
data['isSupportCatEye'] = isSupportCatEye;
data['isSupportBackupBattery'] = isSupportBackupBattery;
data['isNoSupportedBlueBroadcast'] = isNoSupportedBlueBroadcast;
data['wifiLockType'] = wifiLockType;
data['wifi'] = wifi;
data['isH264'] = isH264;
data['isH265'] = isH265;
data['isMJpeg'] = isMJpeg;
return data;
}
@override
String toString() {
return 'LockFeature{password: $password, passwordIssue: $passwordIssue, icCard: $icCard, fingerprint: $fingerprint, fingerVein: $fingerVein, palmVein: $palmVein, isSupportIris: $isSupportIris, d3Face: $d3Face, bluetoothRemoteControl: $bluetoothRemoteControl, videoIntercom: $videoIntercom, isSupportCatEye: $isSupportCatEye, isSupportBackupBattery: $isSupportBackupBattery, isNoSupportedBlueBroadcast: $isNoSupportedBlueBroadcast, wifiLockType: $wifiLockType, wifi: $wifi, isH264: $isH264, isH265: $isH265, isMJpeg: $isMJpeg}';
}
}
class LockSetting {
LockSetting({
this.attendance,
this.appUnlockOnline,
this.remoteUnlock,
this.catEyeConfig,
});
// 从 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()
: [],
);
}
int? attendance;
int? appUnlockOnline;
int? remoteUnlock;
List<CatEyeConfig>? catEyeConfig;
// 将对象转换为 JSON 数据
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['attendance'] = attendance;
data['appUnlockOnline'] = appUnlockOnline;
data['remoteUnlock'] = remoteUnlock;
if (catEyeConfig != null) {
data['catEyeConfig'] =
catEyeConfig!.map((v) => v.toJson()).toList(); // 序列化为 List
}
return data;
}
@override
String toString() {
return 'LockSetting{attendance: $attendance, appUnlockOnline: $appUnlockOnline, remoteUnlock: $remoteUnlock, catEyeConfig: $catEyeConfig}';
}
}
// 定义 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}';
}
}