// // JXDrama.m // AICity // // Created by TogetherWatch on 2025-10-13. // Feature: 003-ios-api-https - 剧星短剧平台API接入 // #import "JXDrama.h" @implementation JXDrama - (instancetype)initWithDictionary:(NSDictionary *)dict { self = [super init]; if (self) { _id = [dict[@"id"] integerValue]; _jxDramaId = dict[@"jx_drama_id"]; _title = dict[@"title"]; _cover = dict[@"cover"]; _desc = dict[@"description"]; _category = dict[@"category"]; _rating = [dict[@"rating"] floatValue]; _totalEpisodes = [dict[@"total_episodes"] integerValue]; _isPaid = [dict[@"is_paid"] boolValue]; _viewCount = [dict[@"view_count"] integerValue]; _authorInfo = dict[@"author_info"]; // 处理标签数组 id tagsObj = dict[@"tags"]; if ([tagsObj isKindOfClass:[NSArray class]]) { _tags = tagsObj; } else if ([tagsObj isKindOfClass:[NSString class]]) { // 如果是逗号分隔的字符串,转换为数组 _tags = [tagsObj componentsSeparatedByString:@","]; } else { _tags = @[]; } } return self; } - (NSDictionary *)toDictionary { return @{ @"id": @(self.id), @"jx_drama_id": self.jxDramaId ?: @"", @"title": self.title ?: @"", @"cover": self.cover ?: @"", @"description": self.desc ?: @"", @"category": self.category ?: @"", @"tags": self.tags ?: @[], @"rating": @(self.rating), @"total_episodes": @(self.totalEpisodes), @"is_paid": @(self.isPaid), @"view_count": @(self.viewCount), @"author_info": self.authorInfo ?: @"" }; } @end