初始提交
This commit is contained in:
29
bin/model/api_response.dart
Normal file
29
bin/model/api_response.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
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 原始响应对象
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user