class ApiResponse<T> {
  int? code;
  T? data;
  String? msg;
  int? total;
  dynamic rawResponse; // 原始 Dio 响应对象

  ApiResponse({
    required this.code,
    this.data,
    this.msg,
    this.total,
    this.rawResponse,
  });

  factory ApiResponse.fromJson(
    Map<String, dynamic> json,
    T Function(Object?) fromJsonT, {
    dynamic rawResponse,
  }) {
    return ApiResponse<T>(
      code: json['code'] as int?,
      data: json['data'] != null ? fromJsonT(json['data']) : null,
      msg: json['msg'] as String?,
      total: json['total'] as int?,
      rawResponse: rawResponse, // 保留 Dio 原始响应对象
    );
  }
}
