Files
WebApp/ShenQi/PushRecordList.m
2025-01-11 14:58:16 +08:00

137 lines
5.9 KiB
Objective-C

//
// PushRecordList.m
//
// Created by on 2025/1/11
// Copyright (c) 2025 zL. All rights reserved.
//
#import "PushRecordList.h"
NSString *const kPushRecordListStatus = @"status";
NSString *const kPushRecordListContent = @"content";
NSString *const kPushRecordListUserId = @"userId";
NSString *const kPushRecordListJumpUrl = @"jumpUrl";
NSString *const kPushRecordListReceiveTimes = @"receiveTimes";
NSString *const kPushRecordListRecordId = @"recordId";
NSString *const kPushRecordListImage = @"image";
NSString *const kPushRecordListTitle = @"title";
NSString *const kPushRecordListType = @"type";
NSString *const kPushRecordListCreateTime = @"createTime";
@interface PushRecordList ()
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
@end
@implementation PushRecordList
@synthesize status = _status;
@synthesize content = _content;
@synthesize userId = _userId;
@synthesize jumpUrl = _jumpUrl;
@synthesize receiveTimes = _receiveTimes;
@synthesize recordId = _recordId;
@synthesize image = _image;
@synthesize title = _title;
@synthesize type = _type;
@synthesize createTime = _createTime;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
return [[self alloc] initWithDictionary:dict];
}
- (instancetype)initWithDictionary:(NSDictionary *)dict {
self = [super init];
// This check serves to make sure that a non-NSDictionary object
// passed into the model class doesn't break the parsing.
if (self && [dict isKindOfClass:[NSDictionary class]]) {
self.status = [[self objectOrNilForKey:kPushRecordListStatus fromDictionary:dict] intValue];
self.content = [self objectOrNilForKey:kPushRecordListContent fromDictionary:dict];
self.userId = [[self objectOrNilForKey:kPushRecordListUserId fromDictionary:dict] intValue];
self.jumpUrl = [self objectOrNilForKey:kPushRecordListJumpUrl fromDictionary:dict];
self.receiveTimes = [[self objectOrNilForKey:kPushRecordListReceiveTimes fromDictionary:dict] intValue];
self.recordId = [[self objectOrNilForKey:kPushRecordListRecordId fromDictionary:dict] intValue];
self.image = [self objectOrNilForKey:kPushRecordListImage fromDictionary:dict];
self.title = [self objectOrNilForKey:kPushRecordListTitle fromDictionary:dict];
self.type = [[self objectOrNilForKey:kPushRecordListType fromDictionary:dict] intValue];
self.createTime = [self objectOrNilForKey:kPushRecordListCreateTime fromDictionary:dict];
}
return self;
}
- (NSDictionary *)dictionaryRepresentation {
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
[mutableDict setValue:[NSNumber numberWithInteger:self.status] forKey:kPushRecordListStatus];
[mutableDict setValue:self.content forKey:kPushRecordListContent];
[mutableDict setValue:[NSNumber numberWithInteger:self.userId] forKey:kPushRecordListUserId];
[mutableDict setValue:self.jumpUrl forKey:kPushRecordListJumpUrl];
[mutableDict setValue:[NSNumber numberWithInteger:self.receiveTimes] forKey:kPushRecordListReceiveTimes];
[mutableDict setValue:[NSNumber numberWithInteger:self.recordId] forKey:kPushRecordListRecordId];
[mutableDict setValue:self.image forKey:kPushRecordListImage];
[mutableDict setValue:self.title forKey:kPushRecordListTitle];
[mutableDict setValue:[NSNumber numberWithInteger:self.type] forKey:kPushRecordListType];
[mutableDict setValue:self.createTime forKey:kPushRecordListCreateTime];
return [NSDictionary dictionaryWithDictionary:mutableDict];
}
- (NSString *)description {
return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}
#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
id object = [dict objectForKey:aKey];
return [object isEqual:[NSNull null]] ? nil : object;
}
#pragma mark - NSCoding Methods
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
self.status = [aDecoder decodeIntegerForKey:kPushRecordListStatus];
self.content = [aDecoder decodeObjectForKey:kPushRecordListContent];
self.userId = [aDecoder decodeIntegerForKey:kPushRecordListUserId];
self.jumpUrl = [aDecoder decodeObjectForKey:kPushRecordListJumpUrl];
self.receiveTimes = [aDecoder decodeIntegerForKey:kPushRecordListReceiveTimes];
self.recordId = [aDecoder decodeIntegerForKey:kPushRecordListRecordId];
self.image = [aDecoder decodeObjectForKey:kPushRecordListImage];
self.title = [aDecoder decodeObjectForKey:kPushRecordListTitle];
self.type = [aDecoder decodeIntegerForKey:kPushRecordListType];
self.createTime = [aDecoder decodeObjectForKey:kPushRecordListCreateTime];
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeInteger:_status forKey:kPushRecordListStatus];
[aCoder encodeObject:_content forKey:kPushRecordListContent];
[aCoder encodeInteger:_userId forKey:kPushRecordListUserId];
[aCoder encodeObject:_jumpUrl forKey:kPushRecordListJumpUrl];
[aCoder encodeInteger:_receiveTimes forKey:kPushRecordListReceiveTimes];
[aCoder encodeInteger:_recordId forKey:kPushRecordListRecordId];
[aCoder encodeObject:_image forKey:kPushRecordListImage];
[aCoder encodeObject:_title forKey:kPushRecordListTitle];
[aCoder encodeInteger:_type forKey:kPushRecordListType];
[aCoder encodeObject:_createTime forKey:kPushRecordListCreateTime];
}
- (id)copyWithZone:(NSZone *)zone {
PushRecordList *copy = [[PushRecordList alloc] init];
if (copy) {
copy.status = self.status;
copy.content = [self.content copyWithZone:zone];
copy.userId = self.userId;
copy.jumpUrl = [self.jumpUrl copyWithZone:zone];
copy.receiveTimes = self.receiveTimes;
copy.recordId = self.recordId;
copy.image = [self.image copyWithZone:zone];
copy.title = [self.title copyWithZone:zone];
copy.type = self.type;
copy.createTime = [self.createTime copyWithZone:zone];
}
return copy;
}
@end