fix(client): 兼容后端 Long 字段字符串化(id 与计数)
后端 J1 起 Long/long 一律以字符串下发(含雪花 id 与 viewCount/expiresIn)。 客户端 id 方向本来就是 (json['id'] ?? '').toString(),不受影响;会被 as num? 打挂的 是 Long 计数,这里加统一兼容解析并替换 3 处: - lib/core/data/models/json_numbers.dart(新增,接受数字或数字字符串) - lib/core/data/models/auth_session.dart(expiresIn,后端 long) - lib/core/data/models/drama.dart(viewCount,后端 Long ×2) - test/core/json_id_parsing_test.dart(新增 8 条回归用例) 其余 as num?(durationSec/unlockCoin/number/totalEpisodes/freeEpisodes/code)对应后端 Integer/int,仍是数字,未改动;未碰任何业务逻辑与 UI。
This commit is contained in:
1 parent
61454e36b1
commit
94ff9f1177
4 files changed
+125
-3
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import 'json_numbers.dart';
|
||||
|
||||
/// 短剧与剧集,字段与后端 `/app/**` 的下发结构对应。
|
||||
///
|
||||
/// 封面与播放地址都是后端返回的相对路径(`/files/...`),
|
||||
@@ -98,7 +100,8 @@ class Drama {
|
||||
genre: json['genre'] as String? ?? '',
|
||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||
isHot: json['isHot'] == true,
|
||||
viewCount: (json['viewCount'] as num?)?.toInt() ?? 0,
|
||||
// viewCount 后端是 Long,按字符串下发(见 json_numbers.dart)
|
||||
viewCount: jsonToInt(json['viewCount']),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -114,7 +117,7 @@ class Drama {
|
||||
totalEpisodes: (json['totalEpisodes'] as num?)?.toInt() ?? 0,
|
||||
freeEpisodes: (json['freeEpisodes'] as num?)?.toInt() ?? 0,
|
||||
isHot: json['isHot'] == true,
|
||||
viewCount: (json['viewCount'] as num?)?.toInt() ?? 0,
|
||||
viewCount: jsonToInt(json['viewCount']),
|
||||
detailLoaded: true,
|
||||
episodes: (json['episodes'] as List? ?? const [])
|
||||
.whereType<Map<String, dynamic>>()
|
||||
|
||||
Reference in new issue
Block a user