parse method
Implementation
@override
HzyNormalResponse parse(Response response) {
var json = response.data as Map<String, dynamic>?;
if (json == null) {
return HzyNormalResponse.fail(
data: json,
errorMsg: '请求的数据为空',
errorCode: -1,
);
}
var status = json[_statusKey];
int code = 0;
if (status is bool) {
if (status) {
code = 1;
}
} else {
if (status == _successCode) {
code = 1;
} else {
code = status;
}
}
if (code == 1) {
return HzyNormalResponse.success(
netData: json[_dataKey],
response: json,
reqMsg: json[_msgKey] ?? "",
);
}
return HzyNormalResponse.fail(
errorMsg: json[_msgKey] ?? "",
errorCode: code,
data: json[_dataKey] ?? json,
);
}