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 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 => '会员', _ => '免费', }; factory HistoryItem.fromJson(Map json) => HistoryItem( video: VideoItem.fromJson( (json['video'] as Map?) ?? const {}, ), watchedAt: (json['watched_at'] as String?) ?? '', costType: (json['cost_type'] as num?)?.toInt() ?? 0, ); }