| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // JXInteraction.m
- // AICity
- //
- // Created by TogetherWatch on 2025-10-13.
- //
- #import "JXInteraction.h"
- #import "JXCountFormatter.h"
- @implementation JXInteraction
- - (instancetype)initWithDictionary:(NSDictionary *)dict {
- self = [super init];
- if (self) {
- _jxDramaId = dict[@"jx_drama_id"];
- _jxEpisodeId = dict[@"jx_episode_id"];
- _likeCount = [dict[@"like_count"] longLongValue];
- _commentCount = [dict[@"comment_count"] longLongValue];
- _shareCount = [dict[@"share_count"] longLongValue];
- _favoriteCount = [dict[@"favorite_count"] longLongValue];
- _followCount = [dict[@"follow_count"] longLongValue];
- _viewCount = [dict[@"view_count"] longLongValue];
-
- // 解析日期
- NSString *dateStr = dict[@"last_updated"];
- if (dateStr) {
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ";
- _lastUpdated = [formatter dateFromString:dateStr];
- }
- }
- return self;
- }
- - (NSDictionary *)toDictionary {
- return @{
- @"jx_drama_id": self.jxDramaId ?: @"",
- @"jx_episode_id": self.jxEpisodeId ?: @"",
- @"like_count": @(self.likeCount),
- @"comment_count": @(self.commentCount),
- @"share_count": @(self.shareCount),
- @"favorite_count": @(self.favoriteCount),
- @"follow_count": @(self.followCount),
- @"view_count": @(self.viewCount)
- };
- }
- #pragma mark - UI格式化方法
- - (NSString *)formattedLikeCount {
- return [JXCountFormatter formatLikeCount:self.likeCount];
- }
- - (NSString *)formattedCommentCount {
- return [JXCountFormatter formatCommentCount:self.commentCount];
- }
- - (NSString *)formattedShareCount {
- return [JXCountFormatter formatShareCount:self.shareCount];
- }
- - (NSString *)formattedFavoriteCount {
- return [JXCountFormatter formatFavoriteCount:self.favoriteCount];
- }
- - (NSString *)formattedViewCount {
- return [JXCountFormatter formatPlayCount:self.viewCount];
- }
- /**
- * 兼容旧代码的格式化方法(已废弃,建议使用JXCountFormatter)
- */
- - (NSString *)formatCount:(long long)count {
- return [JXCountFormatter formatCount:count];
- }
- @end
|