|
@@ -0,0 +1,172 @@
|
|
|
+//
|
|
|
+// SongListModel.m
|
|
|
+//
|
|
|
+// Created by on 2020/7/21
|
|
|
+// Copyright (c) 2020 __MyCompanyName__. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "SongListModel.h"
|
|
|
+
|
|
|
+
|
|
|
+NSString *const kSongListModelId = @"id";
|
|
|
+NSString *const kSongListModelSubjectList = @"subjectList";
|
|
|
+NSString *const kSongListModelDelFlag = @"delFlag";
|
|
|
+NSString *const kSongListModelSongAuthor = @"songAuthor";
|
|
|
+NSString *const kSongListModelSongName = @"songName";
|
|
|
+NSString *const kSongListModelTenantId = @"tenantId";
|
|
|
+NSString *const kSongListModelType = @"type";
|
|
|
+NSString *const kSongListModelFileUrlList = @"fileUrlList";
|
|
|
+NSString *const kSongListModelCreateTime = @"createTime";
|
|
|
+NSString *const kSongListModelSubjectNames = @"subjectNames";
|
|
|
+NSString *const kSongListModelLevelList = @"levelList";
|
|
|
+NSString *const kSongListModelUpdateTime = @"updateTime";
|
|
|
+
|
|
|
+
|
|
|
+@interface SongListModel ()
|
|
|
+
|
|
|
+- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation SongListModel
|
|
|
+
|
|
|
+@synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
|
|
|
+@synthesize subjectList = _subjectList;
|
|
|
+@synthesize delFlag = _delFlag;
|
|
|
+@synthesize songAuthor = _songAuthor;
|
|
|
+@synthesize songName = _songName;
|
|
|
+@synthesize tenantId = _tenantId;
|
|
|
+@synthesize type = _type;
|
|
|
+@synthesize fileUrlList = _fileUrlList;
|
|
|
+@synthesize createTime = _createTime;
|
|
|
+@synthesize subjectNames = _subjectNames;
|
|
|
+@synthesize levelList = _levelList;
|
|
|
+@synthesize updateTime = _updateTime;
|
|
|
+
|
|
|
+
|
|
|
++ (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.internalBaseClassIdentifier = [[self objectOrNilForKey:kSongListModelId fromDictionary:dict] doubleValue];
|
|
|
+ self.subjectList = [self objectOrNilForKey:kSongListModelSubjectList fromDictionary:dict];
|
|
|
+ self.delFlag = [[self objectOrNilForKey:kSongListModelDelFlag fromDictionary:dict] doubleValue];
|
|
|
+ self.songAuthor = [self objectOrNilForKey:kSongListModelSongAuthor fromDictionary:dict];
|
|
|
+ self.songName = [self objectOrNilForKey:kSongListModelSongName fromDictionary:dict];
|
|
|
+ self.tenantId = [self objectOrNilForKey:kSongListModelTenantId fromDictionary:dict];
|
|
|
+ self.type = [self objectOrNilForKey:kSongListModelType fromDictionary:dict];
|
|
|
+ self.fileUrlList = [self objectOrNilForKey:kSongListModelFileUrlList fromDictionary:dict];
|
|
|
+ self.createTime = [self objectOrNilForKey:kSongListModelCreateTime fromDictionary:dict];
|
|
|
+ self.subjectNames = [self objectOrNilForKey:kSongListModelSubjectNames fromDictionary:dict];
|
|
|
+ self.levelList = [self objectOrNilForKey:kSongListModelLevelList fromDictionary:dict];
|
|
|
+ self.updateTime = [self objectOrNilForKey:kSongListModelUpdateTime fromDictionary:dict];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return self;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (NSDictionary *)dictionaryRepresentation
|
|
|
+{
|
|
|
+ NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.internalBaseClassIdentifier] forKey:kSongListModelId];
|
|
|
+ [mutableDict setValue:self.subjectList forKey:kSongListModelSubjectList];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.delFlag] forKey:kSongListModelDelFlag];
|
|
|
+ [mutableDict setValue:self.songAuthor forKey:kSongListModelSongAuthor];
|
|
|
+ [mutableDict setValue:self.songName forKey:kSongListModelSongName];
|
|
|
+ [mutableDict setValue:self.tenantId forKey:kSongListModelTenantId];
|
|
|
+ [mutableDict setValue:self.type forKey:kSongListModelType];
|
|
|
+ [mutableDict setValue:self.fileUrlList forKey:kSongListModelFileUrlList];
|
|
|
+ [mutableDict setValue:self.createTime forKey:kSongListModelCreateTime];
|
|
|
+ [mutableDict setValue:self.subjectNames forKey:kSongListModelSubjectNames];
|
|
|
+ [mutableDict setValue:self.levelList forKey:kSongListModelLevelList];
|
|
|
+ [mutableDict setValue:self.updateTime forKey:kSongListModelUpdateTime];
|
|
|
+
|
|
|
+ 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.internalBaseClassIdentifier = [aDecoder decodeDoubleForKey:kSongListModelId];
|
|
|
+ self.subjectList = [aDecoder decodeObjectForKey:kSongListModelSubjectList];
|
|
|
+ self.delFlag = [aDecoder decodeDoubleForKey:kSongListModelDelFlag];
|
|
|
+ self.songAuthor = [aDecoder decodeObjectForKey:kSongListModelSongAuthor];
|
|
|
+ self.songName = [aDecoder decodeObjectForKey:kSongListModelSongName];
|
|
|
+ self.tenantId = [aDecoder decodeObjectForKey:kSongListModelTenantId];
|
|
|
+ self.type = [aDecoder decodeObjectForKey:kSongListModelType];
|
|
|
+ self.fileUrlList = [aDecoder decodeObjectForKey:kSongListModelFileUrlList];
|
|
|
+ self.createTime = [aDecoder decodeObjectForKey:kSongListModelCreateTime];
|
|
|
+ self.subjectNames = [aDecoder decodeObjectForKey:kSongListModelSubjectNames];
|
|
|
+ self.levelList = [aDecoder decodeObjectForKey:kSongListModelLevelList];
|
|
|
+ self.updateTime = [aDecoder decodeObjectForKey:kSongListModelUpdateTime];
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
|
+{
|
|
|
+
|
|
|
+ [aCoder encodeDouble:_internalBaseClassIdentifier forKey:kSongListModelId];
|
|
|
+ [aCoder encodeObject:_subjectList forKey:kSongListModelSubjectList];
|
|
|
+ [aCoder encodeDouble:_delFlag forKey:kSongListModelDelFlag];
|
|
|
+ [aCoder encodeObject:_songAuthor forKey:kSongListModelSongAuthor];
|
|
|
+ [aCoder encodeObject:_songName forKey:kSongListModelSongName];
|
|
|
+ [aCoder encodeObject:_tenantId forKey:kSongListModelTenantId];
|
|
|
+ [aCoder encodeObject:_type forKey:kSongListModelType];
|
|
|
+ [aCoder encodeObject:_fileUrlList forKey:kSongListModelFileUrlList];
|
|
|
+ [aCoder encodeObject:_createTime forKey:kSongListModelCreateTime];
|
|
|
+ [aCoder encodeObject:_subjectNames forKey:kSongListModelSubjectNames];
|
|
|
+ [aCoder encodeObject:_levelList forKey:kSongListModelLevelList];
|
|
|
+ [aCoder encodeObject:_updateTime forKey:kSongListModelUpdateTime];
|
|
|
+}
|
|
|
+
|
|
|
+- (id)copyWithZone:(NSZone *)zone
|
|
|
+{
|
|
|
+ SongListModel *copy = [[SongListModel alloc] init];
|
|
|
+
|
|
|
+ if (copy) {
|
|
|
+
|
|
|
+ copy.internalBaseClassIdentifier = self.internalBaseClassIdentifier;
|
|
|
+ copy.subjectList = [self.subjectList copyWithZone:zone];
|
|
|
+ copy.delFlag = self.delFlag;
|
|
|
+ copy.songAuthor = [self.songAuthor copyWithZone:zone];
|
|
|
+ copy.songName = [self.songName copyWithZone:zone];
|
|
|
+ copy.tenantId = [self.tenantId copyWithZone:zone];
|
|
|
+ copy.type = [self.type copyWithZone:zone];
|
|
|
+ copy.fileUrlList = [self.fileUrlList copyWithZone:zone];
|
|
|
+ copy.createTime = [self.createTime copyWithZone:zone];
|
|
|
+ copy.subjectNames = [self.subjectNames copyWithZone:zone];
|
|
|
+ copy.levelList = [self.levelList copyWithZone:zone];
|
|
|
+ copy.updateTime = [self.updateTime copyWithZone:zone];
|
|
|
+ }
|
|
|
+
|
|
|
+ return copy;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|