056970d8
Key
feat: api
|
1
2
3
4
5
6
|
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: camel_case_types
// ignore_for_file: prefer_single_quotes
// This file is automatically generated. DO NOT EDIT, all your changes would be lost.
import 'package:flutter/material.dart' show debugPrint;
|
795acc7e
Key
feat: aliyun oss ...
|
7
|
import 'package:wow_english/models/aliyun_oss_upload_sts_entity.dart';
|
28f20da9
吴启风
feat:针对apple审核对支付...
|
8
|
import 'package:wow_english/models/app_config_entity.dart';
|
2c079546
吴启风
feat:应用内更新接口替换
|
9
|
import 'package:wow_english/models/app_version_entity.dart';
|
8988aa69
liangchengyou
feat:首页+课程列表数据获取
|
10
|
import 'package:wow_english/models/course_entity.dart';
|
bcd47f52
Key
fixed: 接口list范型支持
|
11
|
import 'package:wow_english/models/course_module_entity.dart';
|
2eb67dd4
liangchengyou
feat:调整代码
|
12
|
import 'package:wow_english/models/course_process_entity.dart';
|
2187c85f
吴启风
feat:课程结构调整
|
13
|
import 'package:wow_english/models/course_section_entity.dart';
|
2a3621f8
吴启风
feat:课程层级调整(增加unit层)
|
14
|
import 'package:wow_english/models/course_unit_entity.dart';
|
2eb67dd4
liangchengyou
feat:调整代码
|
15
|
import 'package:wow_english/models/follow_read_entity.dart';
|
993c1a04
liangchengyou
feat:添加数据模型
|
16
|
import 'package:wow_english/models/listen_entity.dart';
|
99b94d6c
吴启风
feat:首页增加信息弹窗
|
17
|
import 'package:wow_english/models/popup_entity.dart';
|
4224b3f8
吴启风
feat:支付详情页ui
|
18
|
import 'package:wow_english/models/product_entity.dart';
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
19
|
import 'package:wow_english/models/read_content_entity.dart';
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
20
|
import 'package:wow_english/models/singsound_result_detail_entity.dart';
|
056970d8
Key
feat: api
|
21
22
23
|
import 'package:wow_english/models/user_entity.dart';
JsonConvert jsonConvert = JsonConvert();
|
4224b3f8
吴启风
feat:支付详情页ui
|
24
|
|
056970d8
Key
feat: api
|
25
26
|
typedef JsonConvertFunction<T> = T Function(Map<String, dynamic> json);
typedef EnumConvertFunction<T> = T Function(String value);
|
4224b3f8
吴启风
feat:支付详情页ui
|
27
28
29
30
31
32
33
34
35
36
|
typedef ConvertExceptionHandler = void Function(Object error, StackTrace stackTrace);
extension MapSafeExt<K, V> on Map<K, V> {
T? getOrNull<T>(K? key) {
if (!containsKey(key) || key == null) {
return null;
} else {
return this[key] as T?;
}
}
}
|
056970d8
Key
feat: api
|
37
38
|
class JsonConvert {
|
4224b3f8
吴启风
feat:支付详情页ui
|
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
static ConvertExceptionHandler? onError;
JsonConvertClassCollection convertFuncMap = JsonConvertClassCollection();
/// When you are in the development, to generate a new model class, hot-reload doesn't find new generation model class, you can build on MaterialApp method called jsonConvert. ReassembleConvertFuncMap (); This method only works in a development environment
/// https://flutter.cn/docs/development/tools/hot-reload
/// class MyApp extends StatelessWidget {
/// const MyApp({Key? key})
/// : super(key: key);
///
/// @override
/// Widget build(BuildContext context) {
/// jsonConvert.reassembleConvertFuncMap();
/// return MaterialApp();
/// }
/// }
void reassembleConvertFuncMap() {
bool isReleaseMode = const bool.fromEnvironment('dart.vm.product');
if (!isReleaseMode) {
convertFuncMap = JsonConvertClassCollection();
}
}
|
056970d8
Key
feat: api
|
60
61
62
63
64
65
66
67
68
69
70
71
|
T? convert<T>(dynamic value, {EnumConvertFunction? enumConvert}) {
if (value == null) {
return null;
}
if (value is T) {
return value;
}
try {
return _asT<T>(value, enumConvert: enumConvert);
} catch (e, stackTrace) {
debugPrint('asT<$T> $e $stackTrace');
|
4224b3f8
吴启风
feat:支付详情页ui
|
72
73
74
|
if (onError != null) {
onError!(e, stackTrace);
}
|
056970d8
Key
feat: api
|
75
76
77
78
|
return null;
}
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
79
80
|
List<T?>? convertList<T>(List<dynamic>? value,
{EnumConvertFunction? enumConvert}) {
|
056970d8
Key
feat: api
|
81
82
83
84
|
if (value == null) {
return null;
}
try {
|
4224b3f8
吴启风
feat:支付详情页ui
|
85
86
|
return value.map((dynamic e) => _asT<T>(e, enumConvert: enumConvert))
.toList();
|
056970d8
Key
feat: api
|
87
88
|
} catch (e, stackTrace) {
debugPrint('asT<$T> $e $stackTrace');
|
4224b3f8
吴启风
feat:支付详情页ui
|
89
90
91
|
if (onError != null) {
onError!(e, stackTrace);
}
|
056970d8
Key
feat: api
|
92
93
94
95
|
return <T>[];
}
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
96
97
|
List<T>? convertListNotNull<T>(dynamic value,
{EnumConvertFunction? enumConvert}) {
|
056970d8
Key
feat: api
|
98
99
100
101
|
if (value == null) {
return null;
}
try {
|
4224b3f8
吴启风
feat:支付详情页ui
|
102
103
|
return (value as List<dynamic>).map((dynamic e) =>
_asT<T>(e, enumConvert: enumConvert)!).toList();
|
056970d8
Key
feat: api
|
104
105
|
} catch (e, stackTrace) {
debugPrint('asT<$T> $e $stackTrace');
|
4224b3f8
吴启风
feat:支付详情页ui
|
106
107
108
|
if (onError != null) {
onError!(e, stackTrace);
}
|
056970d8
Key
feat: api
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
return <T>[];
}
}
T? _asT<T extends Object?>(dynamic value,
{EnumConvertFunction? enumConvert}) {
final String type = T.toString();
final String valueS = value.toString();
if (enumConvert != null) {
return enumConvert(valueS) as T;
} else if (type == "String") {
return valueS as T;
} else if (type == "int") {
final int? intValue = int.tryParse(valueS);
if (intValue == null) {
return double.tryParse(valueS)?.toInt() as T?;
} else {
return intValue as T;
}
} else if (type == "double") {
return double.parse(valueS) as T;
} else if (type == "DateTime") {
return DateTime.parse(valueS) as T;
} else if (type == "bool") {
if (valueS == '0' || valueS == '1') {
return (valueS == '1') as T;
}
return (valueS == 'true') as T;
} else if (type == "Map" || type.startsWith("Map<")) {
return value as T;
} else {
if (convertFuncMap.containsKey(type)) {
|
4224b3f8
吴启风
feat:支付详情页ui
|
141
142
143
|
if (value == null) {
return null;
}
|
42f15f6c
吴启风
feat:模块选择持久化&模块主题...
|
144
145
146
147
148
149
|
var covertFunc = convertFuncMap[type]!;
if (covertFunc is Map<String, dynamic>) {
return covertFunc(value as Map<String, dynamic>) as T;
} else {
return covertFunc(Map<String, dynamic>.from(value)) as T;
}
|
056970d8
Key
feat: api
|
150
|
} else {
|
4224b3f8
吴启风
feat:支付详情页ui
|
151
152
|
throw UnimplementedError(
'$type unimplemented,you can try running the app again');
|
056970d8
Key
feat: api
|
153
154
155
156
|
}
}
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
157
158
159
160
161
162
163
164
165
166
167
|
//list is returned by type
static M? _getListChildType<M>(List<Map<String, dynamic>> data) {
if (<AliyunOssUploadStsEntity>[] is M) {
return data.map<AliyunOssUploadStsEntity>((Map<String, dynamic> e) =>
AliyunOssUploadStsEntity.fromJson(e)).toList() as M;
}
if (<AliyunOssUploadStsCallbackParam>[] is M) {
return data.map<AliyunOssUploadStsCallbackParam>((
Map<String, dynamic> e) =>
AliyunOssUploadStsCallbackParam.fromJson(e)).toList() as M;
}
|
cde7505e
吴启风
feat:应用内升级
|
168
169
170
|
if (<AppConfigEntity>[] is M) {
return data.map<AppConfigEntity>((Map<String, dynamic> e) =>
AppConfigEntity.fromJson(e)).toList() as M;
|
28f20da9
吴启风
feat:针对apple审核对支付...
|
171
|
}
|
2c079546
吴启风
feat:应用内更新接口替换
|
172
173
174
175
|
if (<AppVersionEntity>[] is M) {
return data.map<AppVersionEntity>((Map<String, dynamic> e) =>
AppVersionEntity.fromJson(e)).toList() as M;
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
if (<CourseEntity>[] is M) {
return data.map<CourseEntity>((Map<String, dynamic> e) =>
CourseEntity.fromJson(e)).toList() as M;
}
if (<CourseCourseLessons>[] is M) {
return data.map<CourseCourseLessons>((Map<String, dynamic> e) =>
CourseCourseLessons.fromJson(e)).toList() as M;
}
if (<CourseModuleEntity>[] is M) {
return data.map<CourseModuleEntity>((Map<String, dynamic> e) =>
CourseModuleEntity.fromJson(e)).toList() as M;
}
if (<CourseProcessEntity>[] is M) {
return data.map<CourseProcessEntity>((Map<String, dynamic> e) =>
CourseProcessEntity.fromJson(e)).toList() as M;
}
if (<CourseProcessReadings>[] is M) {
return data.map<CourseProcessReadings>((Map<String, dynamic> e) =>
CourseProcessReadings.fromJson(e)).toList() as M;
}
if (<CourseProcessTopics>[] is M) {
return data.map<CourseProcessTopics>((Map<String, dynamic> e) =>
CourseProcessTopics.fromJson(e)).toList() as M;
}
if (<CourseProcessTopicsTopicAnswerList>[] is M) {
return data.map<CourseProcessTopicsTopicAnswerList>((
Map<String, dynamic> e) =>
CourseProcessTopicsTopicAnswerList.fromJson(e)).toList() as M;
}
if (<CourseProcessVideos>[] is M) {
return data.map<CourseProcessVideos>((Map<String, dynamic> e) =>
CourseProcessVideos.fromJson(e)).toList() as M;
}
|
2187c85f
吴启风
feat:课程结构调整
|
209
210
211
212
|
if (<CourseSectionEntity>[] is M) {
return data.map<CourseSectionEntity>((Map<String, dynamic> e) =>
CourseSectionEntity.fromJson(e)).toList() as M;
}
|
2a3621f8
吴启风
feat:课程层级调整(增加unit层)
|
213
214
215
216
217
218
219
220
|
if (<CourseUnitEntity>[] is M) {
return data.map<CourseUnitEntity>((Map<String, dynamic> e) =>
CourseUnitEntity.fromJson(e)).toList() as M;
}
if (<CourseUnitDetail>[] is M) {
return data.map<CourseUnitDetail>((Map<String, dynamic> e) =>
CourseUnitDetail.fromJson(e)).toList() as M;
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
221
222
223
224
225
226
227
228
|
if (<FollowReadEntity>[] is M) {
return data.map<FollowReadEntity>((Map<String, dynamic> e) =>
FollowReadEntity.fromJson(e)).toList() as M;
}
if (<ListenEntity>[] is M) {
return data.map<ListenEntity>((Map<String, dynamic> e) =>
ListenEntity.fromJson(e)).toList() as M;
}
|
99b94d6c
吴启风
feat:首页增加信息弹窗
|
229
230
231
232
|
if (<PopupEntity>[] is M) {
return data.map<PopupEntity>((Map<String, dynamic> e) =>
PopupEntity.fromJson(e)).toList() as M;
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
233
234
235
236
237
238
239
240
|
if (<ProductEntity>[] is M) {
return data.map<ProductEntity>((Map<String, dynamic> e) =>
ProductEntity.fromJson(e)).toList() as M;
}
if (<ReadContentEntity>[] is M) {
return data.map<ReadContentEntity>((Map<String, dynamic> e) =>
ReadContentEntity.fromJson(e)).toList() as M;
}
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
241
242
243
244
|
if (<SingsoundResultDetailEntity>[] is M) {
return data.map<SingsoundResultDetailEntity>((Map<String, dynamic> e) =>
SingsoundResultDetailEntity.fromJson(e)).toList() as M;
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
245
246
247
248
|
if (<UserEntity>[] is M) {
return data.map<UserEntity>((Map<String, dynamic> e) =>
UserEntity.fromJson(e)).toList() as M;
}
|
056970d8
Key
feat: api
|
249
|
|
4224b3f8
吴启风
feat:支付详情页ui
|
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
|
debugPrint("$M not found");
return null;
}
static M? fromJsonAsT<M>(dynamic json) {
if (json is M) {
return json;
}
if (json is List) {
return _getListChildType<M>(
json.map((dynamic e) => e as Map<String, dynamic>).toList());
} else {
return jsonConvert.convert<M>(json);
}
}
|
795acc7e
Key
feat: aliyun oss ...
|
266
|
}
|
4224b3f8
吴启风
feat:支付详情页ui
|
267
268
269
270
271
272
|
class JsonConvertClassCollection {
Map<String, JsonConvertFunction> convertFuncMap = {
(AliyunOssUploadStsEntity).toString(): AliyunOssUploadStsEntity.fromJson,
(AliyunOssUploadStsCallbackParam)
.toString(): AliyunOssUploadStsCallbackParam.fromJson,
|
cde7505e
吴启风
feat:应用内升级
|
273
|
(AppConfigEntity).toString(): AppConfigEntity.fromJson,
|
2c079546
吴启风
feat:应用内更新接口替换
|
274
|
(AppVersionEntity).toString(): AppVersionEntity.fromJson,
|
4224b3f8
吴启风
feat:支付详情页ui
|
275
276
277
278
279
280
281
282
283
|
(CourseEntity).toString(): CourseEntity.fromJson,
(CourseCourseLessons).toString(): CourseCourseLessons.fromJson,
(CourseModuleEntity).toString(): CourseModuleEntity.fromJson,
(CourseProcessEntity).toString(): CourseProcessEntity.fromJson,
(CourseProcessReadings).toString(): CourseProcessReadings.fromJson,
(CourseProcessTopics).toString(): CourseProcessTopics.fromJson,
(CourseProcessTopicsTopicAnswerList)
.toString(): CourseProcessTopicsTopicAnswerList.fromJson,
(CourseProcessVideos).toString(): CourseProcessVideos.fromJson,
|
2187c85f
吴启风
feat:课程结构调整
|
284
|
(CourseSectionEntity).toString(): CourseSectionEntity.fromJson,
|
2a3621f8
吴启风
feat:课程层级调整(增加unit层)
|
285
286
|
(CourseUnitEntity).toString(): CourseUnitEntity.fromJson,
(CourseUnitDetail).toString(): CourseUnitDetail.fromJson,
|
4224b3f8
吴启风
feat:支付详情页ui
|
287
288
|
(FollowReadEntity).toString(): FollowReadEntity.fromJson,
(ListenEntity).toString(): ListenEntity.fromJson,
|
99b94d6c
吴启风
feat:首页增加信息弹窗
|
289
|
(PopupEntity).toString(): PopupEntity.fromJson,
|
4224b3f8
吴启风
feat:支付详情页ui
|
290
291
|
(ProductEntity).toString(): ProductEntity.fromJson,
(ReadContentEntity).toString(): ReadContentEntity.fromJson,
|
fd737d6a
吴启风
feat:绘本作答结果以单词为单位...
|
292
293
|
(SingsoundResultDetailEntity).toString(): SingsoundResultDetailEntity
.fromJson,
|
4224b3f8
吴启风
feat:支付详情页ui
|
294
295
296
297
298
299
300
301
302
303
304
|
(UserEntity).toString(): UserEntity.fromJson,
};
bool containsKey(String type) {
return convertFuncMap.containsKey(type);
}
JsonConvertFunction? operator [](String key) {
return convertFuncMap[key];
}
}
|