// // JXDramaContent.m // AICity // // Created by TogetherWatch on 2025-10-20. // Feature: 010-ui-ios - iOS平台完整功能实现(对标Android) // #import "JXDramaContent.h" @implementation JXDramaContent #pragma mark - 初始化方法 - (instancetype)init { self = [super init]; if (self) { _dramaId = 0; _likeCount = 0; _isLiked = NO; _favoriteCount = 0; _isFavorited = NO; _commentCount = 0; } return self; } - (instancetype)initWithDictionary:(NSDictionary *)dict { self = [super init]; if (self) { // URL播放方式 _videoUrl = dict[@"video_url"]; _drmToken = dict[@"drmToken"]; // FileID播放方式(DRM推荐) _appId = dict[@"appId"]; _fileId = dict[@"fileId"]; _psign = dict[@"psign"]; _episodeId = dict[@"episodeId"]; // 短剧标识 - 优先使用 "jx_drama_id"(剧星平台ID),用于后端查询 _dramaId = [dict[@"jx_drama_id"] longLongValue] ?: [dict[@"id"] longLongValue]; // 用户交互数据 _likeCount = [dict[@"like_count"] longLongValue]; _isLiked = [dict[@"isLiked"] boolValue]; _favoriteCount = [dict[@"favorite_count"] longLongValue]; _isFavorited = [dict[@"isFavorited"] boolValue]; _commentCount = [dict[@"comment_count"] longLongValue]; // 播放信息 - 后端返回 "cover" 或 "vertical_cover" _title = dict[@"title"]; _coverUrl = dict[@"vertical_cover"] ?: dict[@"cover"]; // 优先使用竖版封面 // 注:description 字段已通过后端返回,但在这里暂时跳过以避免属性冲突 // 如需要可在需要时单独处理 _descriptions = dict[@"description"] ?: dict[@"description"]; // 优先使用竖版封面 } return self; } + (instancetype)dramaContentWithDictionary:(NSDictionary *)dict { return [[self alloc] initWithDictionary:dict]; } - (NSDictionary *)toDictionary { NSMutableDictionary *dict = [NSMutableDictionary dictionary]; // URL播放方式 if (self.videoUrl) dict[@"video_url"] = self.videoUrl; if (self.drmToken) dict[@"drmToken"] = self.drmToken; // FileID播放方式 if (self.appId) dict[@"appId"] = self.appId; if (self.fileId) dict[@"fileId"] = self.fileId; if (self.psign) dict[@"psign"] = self.psign; if (self.episodeId) dict[@"episodeId"] = self.episodeId; // 短剧标识 dict[@"dramaId"] = @(self.dramaId); // 用户交互数据 dict[@"like_count"] = @(self.likeCount); dict[@"isLiked"] = @(self.isLiked); dict[@"favorite_count"] = @(self.favoriteCount); dict[@"isFavorited"] = @(self.isFavorited); dict[@"comment_count"] = @(self.commentCount); // 播放信息 if (self.title) dict[@"title"] = self.title; if (self.coverUrl) dict[@"coverUrl"] = self.coverUrl; if (self.description) dict[@"description"] = self.description; if (self.descriptions) dict[@"descriptions"] = self.descriptions; return [dict copy]; } #pragma mark - 辅助方法 - (BOOL)isFileIdMode { return (self.appId.length > 0 && self.fileId.length > 0 && self.psign.length > 0); } - (BOOL)isUrlMode { return self.videoUrl.length > 0; } #pragma mark - NSObject - (NSString *)description { return [NSString stringWithFormat:@"", self.dramaId, self.title ?: @"(null)", @(self.isFileIdMode), @(self.isUrlMode)]; } @end