import 'package:ftrecruiter/comm/utils/log_utils.dart'; class HttpResult { HttpResult({required this.isSuccess, dynamic dataJson, List? listJson, this.errorCode, this.errorMsg}) { this._dataJson = dataJson; this._listJson = listJson; } //是否成功 bool isSuccess = false; //成功的数据(Json数据) dynamic _dataJson; List? _listJson; //成功的数据(真正的数据) T? data; List? list; //失败的数据 int? errorCode; String? errorMsg; Map? getDataJson() { if (_dataJson is Map) { return _dataJson as Map; } return null; } List? getListJson() { return _listJson; } /// 设置真正的数据对象 void setData(T data) { this.data = data; } void setList(List list) { this.list = list; } /// 基本类型转换为指定的泛型类型 HttpResult convert({T? data, List? list}) { var result = HttpResult( isSuccess: this.isSuccess, dataJson: this._dataJson, listJson: this._listJson, errorCode: this.errorCode, errorMsg: this.errorMsg); result.data = data; result.list = list; return result; } }