1
This commit is contained in:
@@ -14,8 +14,11 @@
|
||||
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
||||
return @{
|
||||
@"commentId" : @"id",
|
||||
@"userName" : @[ @"userName", @"nickname", @"name" ],
|
||||
@"avatarUrl" : @[ @"avatarUrl", @"avatar" ],
|
||||
@"userId" : @"userId",
|
||||
@"userName" : @"userName",
|
||||
@"avatarUrl" : @"userAvatar",
|
||||
@"createTime" : @"createdAt",
|
||||
@"totalReplyCount" : @"replyCount",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,6 +26,24 @@
|
||||
return @{@"replies" : [KBAIReplyModel class]};
|
||||
}
|
||||
|
||||
- (void)setLiked:(NSInteger)liked {
|
||||
// 后端返回的是 NSInteger (0/1),转换为 BOOL
|
||||
_isLiked = (liked == 1);
|
||||
}
|
||||
|
||||
- (void)setCreatedAt:(NSString *)createdAt {
|
||||
// 后端返回的是字符串时间,转换为时间戳
|
||||
if (createdAt && createdAt.length > 0) {
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
|
||||
NSDate *date = [formatter dateFromString:createdAt];
|
||||
if (date) {
|
||||
_createTime = [date timeIntervalSince1970];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
Reference in New Issue
Block a user