12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import 'package:fis_common/json_convert.dart';
- class RpcResult<T> {
- final bool isSuccess;
- final int errorCode;
- final String msg;
- T? data;
- RpcResult({
- required this.isSuccess,
- required this.errorCode,
- required this.msg,
- this.data,
- });
- factory RpcResult.fromJson(Map<String, dynamic> map) {
- T? data;
- if (map['data'] != null) {
- data = FJsonConvert.fromJson<T>(map['data']);
- }
- return RpcResult(
- isSuccess: map['isSuccess'] == true,
- errorCode: map['errorCode'],
- msg: map['msg'],
- data: data,
- );
- }
- }
- /// 分页数据
- class PagedData<T> {
- PagedData({
- required this.currentPage,
- required this.pageSize,
- required this.dataCount,
- this.pageData = const [],
- });
- factory PagedData.fromJson(Map<String, dynamic> map) {
- List<T> dataList = [];
- if (map['PageData'] != null) {
- dataList.addAll(
- (map['PageData'] as List).map((e) => FJsonConvert.fromJson<T>(e)!));
- }
- return PagedData(
- currentPage: map['CurrentPage'],
- pageSize: map['PageSize'],
- dataCount: map['DataCount'],
- pageData: dataList,
- );
- }
- Map<String, dynamic> toJson() {
- Map<String, dynamic> map = {};
- map['CurrentPage'] = this.currentPage;
- map['PageSize'] = this.pageSize;
- map['DataCount'] = this.dataCount;
- map['PageData'] = this.pageData.map((dynamic e) => e.toJson()).toList();
- return map;
- }
- final int currentPage;
- final int pageSize;
- final int dataCount;
- final List<T> pageData;
- }
- /// 分页请求
- class PagedRequest {
- PagedRequest({
- this.currentPage = 1,
- this.pageSize = 10,
- });
- int currentPage;
- int pageSize;
- Map<String, dynamic> toJson() {
- Map<String, dynamic> map = {};
- map['currentPage'] = this.currentPage;
- map['pageSize'] = this.pageSize;
- return map;
- }
- }
|