81 lines
2.0 KiB
Dart
81 lines
2.0 KiB
Dart
|
|
/// TV 应用模型。
|
|||
|
|
///
|
|||
|
|
/// 对应后端 /theme/tvapp/* 接口的 TV 应用实体。
|
|||
|
|
class TvApp {
|
|||
|
|
const TvApp({
|
|||
|
|
required this.id,
|
|||
|
|
required this.appName,
|
|||
|
|
required this.packageName,
|
|||
|
|
required this.appCategory,
|
|||
|
|
required this.iconUrl,
|
|||
|
|
required this.orgId,
|
|||
|
|
required this.groupId,
|
|||
|
|
required this.status,
|
|||
|
|
required this.createTime,
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
/// 应用 ID。
|
|||
|
|
final String id;
|
|||
|
|
|
|||
|
|
/// 应用名称。
|
|||
|
|
final String appName;
|
|||
|
|
|
|||
|
|
/// 包名。
|
|||
|
|
final String packageName;
|
|||
|
|
|
|||
|
|
/// 应用分类。
|
|||
|
|
final String appCategory;
|
|||
|
|
|
|||
|
|
/// 图标地址。
|
|||
|
|
final String iconUrl;
|
|||
|
|
|
|||
|
|
/// 组织 ID。
|
|||
|
|
final String orgId;
|
|||
|
|
|
|||
|
|
/// 设备分组 ID。
|
|||
|
|
final String groupId;
|
|||
|
|
|
|||
|
|
/// 状态(0=正常 1=禁用)。
|
|||
|
|
final int status;
|
|||
|
|
|
|||
|
|
/// 创建时间。
|
|||
|
|
final DateTime? createTime;
|
|||
|
|
|
|||
|
|
factory TvApp.fromJson(Map<String, dynamic> json) {
|
|||
|
|
return TvApp(
|
|||
|
|
id: json['id']?.toString() ?? '',
|
|||
|
|
appName: json['appName']?.toString() ?? '',
|
|||
|
|
packageName: json['packageName']?.toString() ?? '',
|
|||
|
|
appCategory: json['appCategory']?.toString() ?? '',
|
|||
|
|
iconUrl: json['iconUrl']?.toString() ?? '',
|
|||
|
|
orgId: json['orgId']?.toString() ?? '',
|
|||
|
|
groupId: json['groupId']?.toString() ?? '',
|
|||
|
|
status: int.tryParse(json['status']?.toString() ?? '0') ?? 0,
|
|||
|
|
createTime: _parseDateTime(json['createTime']),
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// 兼容 `yyyy-MM-dd HH:mm:ss` 与 ISO 8601 两种时间格式。
|
|||
|
|
static DateTime? _parseDateTime(dynamic value) {
|
|||
|
|
if (value == null) return null;
|
|||
|
|
final text = value.toString().trim();
|
|||
|
|
if (text.isEmpty) return null;
|
|||
|
|
return DateTime.tryParse(text) ??
|
|||
|
|
DateTime.tryParse(text.replaceFirst(' ', 'T'));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Map<String, dynamic> toJson() {
|
|||
|
|
return {
|
|||
|
|
'id': id,
|
|||
|
|
'appName': appName,
|
|||
|
|
'packageName': packageName,
|
|||
|
|
'appCategory': appCategory,
|
|||
|
|
'iconUrl': iconUrl,
|
|||
|
|
'orgId': orgId,
|
|||
|
|
'groupId': groupId,
|
|||
|
|
'status': status,
|
|||
|
|
'createTime': createTime?.toIso8601String(),
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|