JXDrama.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // JXDrama.m
  3. // AICity
  4. //
  5. // Created by TogetherWatch on 2025-10-13.
  6. // Feature: 003-ios-api-https - 剧星短剧平台API接入
  7. //
  8. #import "JXDrama.h"
  9. @implementation JXDrama
  10. - (instancetype)initWithDictionary:(NSDictionary *)dict {
  11. self = [super init];
  12. if (self) {
  13. _id = [dict[@"id"] integerValue];
  14. _jxDramaId = dict[@"jx_drama_id"];
  15. _title = dict[@"title"];
  16. _cover = dict[@"cover"];
  17. _desc = dict[@"description"];
  18. _category = dict[@"category"];
  19. _rating = [dict[@"rating"] floatValue];
  20. _totalEpisodes = [dict[@"total_episodes"] integerValue];
  21. _isPaid = [dict[@"is_paid"] boolValue];
  22. _viewCount = [dict[@"view_count"] integerValue];
  23. _authorInfo = dict[@"author_info"];
  24. // 处理标签数组
  25. id tagsObj = dict[@"tags"];
  26. if ([tagsObj isKindOfClass:[NSArray class]]) {
  27. _tags = tagsObj;
  28. } else if ([tagsObj isKindOfClass:[NSString class]]) {
  29. // 如果是逗号分隔的字符串,转换为数组
  30. _tags = [tagsObj componentsSeparatedByString:@","];
  31. } else {
  32. _tags = @[];
  33. }
  34. }
  35. return self;
  36. }
  37. - (NSDictionary *)toDictionary {
  38. return @{
  39. @"id": @(self.id),
  40. @"jx_drama_id": self.jxDramaId ?: @"",
  41. @"title": self.title ?: @"",
  42. @"cover": self.cover ?: @"",
  43. @"description": self.desc ?: @"",
  44. @"category": self.category ?: @"",
  45. @"tags": self.tags ?: @[],
  46. @"rating": @(self.rating),
  47. @"total_episodes": @(self.totalEpisodes),
  48. @"is_paid": @(self.isPaid),
  49. @"view_count": @(self.viewCount),
  50. @"author_info": self.authorInfo ?: @""
  51. };
  52. }
  53. @end