import 'package:equatable/equatable.dart';

class AlertListBO extends Equatable {
  final int total;
  final AlertListTabCountBO tabCount;
  final List<AlertListItemBO> rows;

  const AlertListBO({
    required this.total,
    required this.tabCount,
    required this.rows,
  });

  factory AlertListBO.fromJson(Map<String, dynamic> json) {
    return AlertListBO(
      total: json['total'] as int? ?? 0,
      tabCount: AlertListTabCountBO.fromJson(
        json['tabCount'] as Map<String, dynamic>? ?? {},
      ),
      rows: (json['rows'] as List<dynamic>?)
              ?.map(
                  (e) => AlertListItemBO.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }

  @override
  List<Object?> get props => [total, tabCount, rows];
}

class AlertListTabCountBO extends Equatable {
  final int all;
  final int pending;
  final int processed;
  final int falseAlarm;

  const AlertListTabCountBO({
    required this.all,
    required this.pending,
    required this.processed,
    required this.falseAlarm,
  });

  factory AlertListTabCountBO.fromJson(Map<String, dynamic> json) {
    return AlertListTabCountBO(
      all: json['all'] as int? ?? 0,
      pending: json['pending'] as int? ?? 0,
      processed: json['processed'] as int? ?? 0,
      falseAlarm: json['falseAlarm'] as int? ?? 0,
    );
  }

  @override
  List<Object?> get props => [all, pending, processed, falseAlarm];
}

class AlertListItemBO extends Equatable {
  final int alertId;
  final String alertTitle;
  final String alertIcon;
  final String deviceName;
  final String deviceLocation;
  final String alertTime;
  final String handleTime;
  final String alertLevel;//1=中警 3=高警
  final String alertStatus;//0=待处理 1=处理中 2=已确认 3=已关闭 4=误报关闭

  const AlertListItemBO({
    required this.alertId,
    required this.alertTitle,
    required this.alertIcon,
    required this.deviceName,
    required this.deviceLocation,
    required this.alertTime,
    required this.handleTime,
    required this.alertLevel,
    required this.alertStatus,
  });

  factory AlertListItemBO.fromJson(Map<String, dynamic> json) {
    return AlertListItemBO(
      alertId: json['alertId'] as int? ?? 0,
      alertTitle: json['alertTitle'] as String? ?? '',
      alertIcon: json['alertIcon'] as String? ?? '',
      deviceName: json['deviceName'] as String? ?? '',
      deviceLocation: json['deviceLocation'] as String? ?? '',
      alertTime: json['alertTime'] as String? ?? '',
      handleTime: json['handleTime'] as String? ?? '',
      alertLevel: json['alertLevel'] as String? ?? '',
      alertStatus: json['alertStatus'] as String? ?? '',
    );
  }

  @override
  List<Object?> get props => [
        alertId,
        alertTitle,
        alertIcon,
        deviceName,
        deviceLocation,
        alertTime,
        handleTime,
        alertLevel,
        alertStatus,
      ];
}