This commit is contained in:
macbook_max
2026-10-15 20:36:59 +08:00
commit 6bf949949c
7923 changed files with 1369582 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
import 'video_item.dart';
/// 用户公开主页(《03-接口文档》4.7)
class UserPublicProfile {
UserPublicProfile({
required this.userId,
this.nickname = '',
this.avatarUrl = '',
this.bio = '',
this.videoCount = 0,
this.totalLikes = 0,
});
final int userId;
final String nickname;
final String avatarUrl;
final String bio;
/// 已发布作品数
final int videoCount;
/// 累计获赞
final int totalLikes;
factory UserPublicProfile.fromJson(Map<String, dynamic> json) =>
UserPublicProfile(
userId: (json['user_id'] as num?)?.toInt() ?? 0,
nickname: (json['nickname'] as String?) ?? '',
avatarUrl: (json['avatar_url'] as String?) ?? '',
bio: (json['bio'] as String?) ?? '',
videoCount: (json['video_count'] as num?)?.toInt() ?? 0,
totalLikes: (json['total_likes'] as num?)?.toInt() ?? 0,
);
}
/// 观看历史项(《03-接口文档》6.7:video + watched_at + cost_type)
class HistoryItem {
HistoryItem({
required this.video,
this.watchedAt = '',
this.costType = 0,
});
final VideoItem video;
final String watchedAt;
/// 计费类型:0 免费额度 / 1 积分 / 2 会员 / 3 重复或本人
final int costType;
String get costLabel => switch (costType) {
1 => '积分',
2 => '会员',
3 => '免费',
_ => '免费',
};
factory HistoryItem.fromJson(Map<String, dynamic> json) => HistoryItem(
video: VideoItem.fromJson(
(json['video'] as Map<String, dynamic>?) ?? const {},
),
watchedAt: (json['watched_at'] as String?) ?? '',
costType: (json['cost_type'] as num?)?.toInt() ?? 0,
);
}