| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- //
- // VideoCourseModel.m
- //
- // Created by Steven on 2024/11/21
- // Copyright (c) 2024 __MyCompanyName__. All rights reserved.
- //
- #import "VideoCourseModel.h"
- NSString *const kVideoCourseModelId = @"id";
- NSString *const kVideoCourseModelLessonCoverUrl = @"lessonCoverUrl";
- NSString *const kVideoCourseModelRealName = @"realName";
- NSString *const kVideoCourseModelLessonCount = @"lessonCount";
- NSString *const kVideoCourseModelMusicNum = @"musicNum";
- NSString *const kVideoCourseModelAuditVersion = @"auditVersion";
- NSString *const kVideoCourseModelLessonSubjectName = @"lessonSubjectName";
- NSString *const kVideoCourseModelLessonDesc = @"lessonDesc";
- NSString *const kVideoCourseModelLessonPrice = @"lessonPrice";
- NSString *const kVideoCourseModelCountStudent = @"countStudent";
- NSString *const kVideoCourseModelLessonName = @"lessonName";
- NSString *const kVideoCourseModelAvatar = @"avatar";
- NSString *const kVideoCourseModelLessonSubject = @"lessonSubject";
- NSString *const kVideoCourseModelPayType = @"payType";
- NSString *const kVideoCourseModelTeacherId = @"teacherId";
- NSString *const kVideoCourseModelRelationType = @"relationType";
- NSString *const kVideoCourseModelUserName = @"userName";
- NSString *const kVideoCourseModelVirtualNumber = @"virtualNumber";
- @interface VideoCourseModel ()
- - (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
- @end
- @implementation VideoCourseModel
- @synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
- @synthesize lessonCoverUrl = _lessonCoverUrl;
- @synthesize realName = _realName;
- @synthesize lessonCount = _lessonCount;
- @synthesize musicNum = _musicNum;
- @synthesize auditVersion = _auditVersion;
- @synthesize lessonSubjectName = _lessonSubjectName;
- @synthesize lessonDesc = _lessonDesc;
- @synthesize lessonPrice = _lessonPrice;
- @synthesize countStudent = _countStudent;
- @synthesize lessonName = _lessonName;
- @synthesize avatar = _avatar;
- @synthesize lessonSubject = _lessonSubject;
- @synthesize payType = _payType;
- @synthesize teacherId = _teacherId;
- @synthesize relationType = _relationType;
- @synthesize userName = _userName;
- @synthesize virtualNumber = _virtualNumber;
- + (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:kVideoCourseModelId fromDictionary:dict];
- self.lessonCoverUrl = [self objectOrNilForKey:kVideoCourseModelLessonCoverUrl fromDictionary:dict];
- self.realName = [self objectOrNilForKey:kVideoCourseModelRealName fromDictionary:dict];
- self.lessonCount = [[self objectOrNilForKey:kVideoCourseModelLessonCount fromDictionary:dict] doubleValue];
- self.musicNum = [[self objectOrNilForKey:kVideoCourseModelMusicNum fromDictionary:dict] integerValue];
- self.auditVersion = [self objectOrNilForKey:kVideoCourseModelAuditVersion fromDictionary:dict];
- self.lessonSubjectName = [self objectOrNilForKey:kVideoCourseModelLessonSubjectName fromDictionary:dict];
- self.lessonDesc = [self objectOrNilForKey:kVideoCourseModelLessonDesc fromDictionary:dict];
- self.lessonPrice = [[self objectOrNilForKey:kVideoCourseModelLessonPrice fromDictionary:dict] doubleValue];
- self.countStudent = [[self objectOrNilForKey:kVideoCourseModelCountStudent fromDictionary:dict] doubleValue];
- self.lessonName = [self objectOrNilForKey:kVideoCourseModelLessonName fromDictionary:dict];
- self.avatar = [self objectOrNilForKey:kVideoCourseModelAvatar fromDictionary:dict];
- self.lessonSubject = [self objectOrNilForKey:kVideoCourseModelLessonSubject fromDictionary:dict];
- self.payType = [self objectOrNilForKey:kVideoCourseModelPayType fromDictionary:dict];
- self.teacherId = [self objectOrNilForKey:kVideoCourseModelTeacherId fromDictionary:dict];
- self.relationType = [self objectOrNilForKey:kVideoCourseModelRelationType fromDictionary:dict];
- self.userName = [self objectOrNilForKey:kVideoCourseModelUserName fromDictionary:dict];
- self.virtualNumber = [[self objectOrNilForKey:kVideoCourseModelVirtualNumber fromDictionary:dict] doubleValue];
- }
-
- return self;
-
- }
- - (NSDictionary *)dictionaryRepresentation
- {
- NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
- [mutableDict setValue:self.internalBaseClassIdentifier forKey:kVideoCourseModelId];
- [mutableDict setValue:self.lessonCoverUrl forKey:kVideoCourseModelLessonCoverUrl];
- [mutableDict setValue:self.realName forKey:kVideoCourseModelRealName];
- [mutableDict setValue:[NSNumber numberWithDouble:self.lessonCount] forKey:kVideoCourseModelLessonCount];
- [mutableDict setValue:[NSNumber numberWithInteger:self.musicNum] forKey:kVideoCourseModelMusicNum];
- [mutableDict setValue:self.auditVersion forKey:kVideoCourseModelAuditVersion];
- [mutableDict setValue:self.lessonSubjectName forKey:kVideoCourseModelLessonSubjectName];
- [mutableDict setValue:self.lessonDesc forKey:kVideoCourseModelLessonDesc];
- [mutableDict setValue:[NSNumber numberWithDouble:self.lessonPrice] forKey:kVideoCourseModelLessonPrice];
- [mutableDict setValue:[NSNumber numberWithDouble:self.countStudent] forKey:kVideoCourseModelCountStudent];
- [mutableDict setValue:self.lessonName forKey:kVideoCourseModelLessonName];
- [mutableDict setValue:self.avatar forKey:kVideoCourseModelAvatar];
- [mutableDict setValue:self.lessonSubject forKey:kVideoCourseModelLessonSubject];
- [mutableDict setValue:self.payType forKey:kVideoCourseModelPayType];
- [mutableDict setValue:self.teacherId forKey:kVideoCourseModelTeacherId];
- [mutableDict setValue:self.relationType forKey:kVideoCourseModelRelationType];
- [mutableDict setValue:self.userName forKey:kVideoCourseModelUserName];
- [mutableDict setValue:[NSNumber numberWithDouble:self.virtualNumber] forKey:kVideoCourseModelVirtualNumber];
- 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];
- if ([object isKindOfClass:[NSNumber class]]) {
- NSNumber *number = object;
- object = [number stringValue];
- }
- return [object isEqual:[NSNull null]] ? nil : object;
- }
- #pragma mark - NSCoding Methods
- - (id)initWithCoder:(NSCoder *)aDecoder
- {
- self = [super init];
- self.internalBaseClassIdentifier = [aDecoder decodeObjectForKey:kVideoCourseModelId];
- self.lessonCoverUrl = [aDecoder decodeObjectForKey:kVideoCourseModelLessonCoverUrl];
- self.realName = [aDecoder decodeObjectForKey:kVideoCourseModelRealName];
- self.lessonCount = [aDecoder decodeDoubleForKey:kVideoCourseModelLessonCount];
- self.musicNum = [aDecoder decodeIntegerForKey:kVideoCourseModelMusicNum];
- self.auditVersion = [aDecoder decodeObjectForKey:kVideoCourseModelAuditVersion];
- self.lessonSubjectName = [aDecoder decodeObjectForKey:kVideoCourseModelLessonSubjectName];
- self.lessonDesc = [aDecoder decodeObjectForKey:kVideoCourseModelLessonDesc];
- self.lessonPrice = [aDecoder decodeDoubleForKey:kVideoCourseModelLessonPrice];
- self.countStudent = [aDecoder decodeDoubleForKey:kVideoCourseModelCountStudent];
- self.lessonName = [aDecoder decodeObjectForKey:kVideoCourseModelLessonName];
- self.avatar = [aDecoder decodeObjectForKey:kVideoCourseModelAvatar];
- self.lessonSubject = [aDecoder decodeObjectForKey:kVideoCourseModelLessonSubject];
- self.payType = [aDecoder decodeObjectForKey:kVideoCourseModelPayType];
- self.teacherId = [aDecoder decodeObjectForKey:kVideoCourseModelTeacherId];
- self.relationType = [aDecoder decodeObjectForKey:kVideoCourseModelRelationType];
- self.userName = [aDecoder decodeObjectForKey:kVideoCourseModelUserName];
- self.virtualNumber = [aDecoder decodeDoubleForKey:kVideoCourseModelVirtualNumber];
- return self;
- }
- - (void)encodeWithCoder:(NSCoder *)aCoder
- {
- [aCoder encodeObject:_internalBaseClassIdentifier forKey:kVideoCourseModelId];
- [aCoder encodeObject:_lessonCoverUrl forKey:kVideoCourseModelLessonCoverUrl];
- [aCoder encodeObject:_realName forKey:kVideoCourseModelRealName];
- [aCoder encodeDouble:_lessonCount forKey:kVideoCourseModelLessonCount];
- [aCoder encodeInteger:_musicNum forKey:kVideoCourseModelMusicNum];
- [aCoder encodeObject:_auditVersion forKey:kVideoCourseModelAuditVersion];
- [aCoder encodeObject:_lessonSubjectName forKey:kVideoCourseModelLessonSubjectName];
- [aCoder encodeObject:_lessonDesc forKey:kVideoCourseModelLessonDesc];
- [aCoder encodeDouble:_lessonPrice forKey:kVideoCourseModelLessonPrice];
- [aCoder encodeDouble:_countStudent forKey:kVideoCourseModelCountStudent];
- [aCoder encodeObject:_lessonName forKey:kVideoCourseModelLessonName];
- [aCoder encodeObject:_avatar forKey:kVideoCourseModelAvatar];
- [aCoder encodeObject:_lessonSubject forKey:kVideoCourseModelLessonSubject];
- [aCoder encodeObject:_payType forKey:kVideoCourseModelPayType];
- [aCoder encodeObject:_teacherId forKey:kVideoCourseModelTeacherId];
- [aCoder encodeObject:_relationType forKey:kVideoCourseModelRelationType];
- [aCoder encodeObject:_userName forKey:kVideoCourseModelUserName];
- [aCoder encodeDouble:_virtualNumber forKey:kVideoCourseModelVirtualNumber];
- }
- - (id)copyWithZone:(NSZone *)zone
- {
- VideoCourseModel *copy = [[VideoCourseModel alloc] init];
-
- if (copy) {
- copy.internalBaseClassIdentifier = [self.internalBaseClassIdentifier copyWithZone:zone];
- copy.lessonCoverUrl = [self.lessonCoverUrl copyWithZone:zone];
- copy.realName = [self.realName copyWithZone:zone];
- copy.lessonCount = self.lessonCount;
- copy.musicNum = self.musicNum;
- copy.auditVersion = [self.auditVersion copyWithZone:zone];
- copy.lessonSubjectName = [self.lessonSubjectName copyWithZone:zone];
- copy.lessonDesc = [self.lessonDesc copyWithZone:zone];
- copy.lessonPrice = self.lessonPrice;
- copy.countStudent = self.countStudent;
- copy.lessonName = [self.lessonName copyWithZone:zone];
- copy.avatar = [self.avatar copyWithZone:zone];
- copy.lessonSubject = [self.lessonSubject copyWithZone:zone];
- copy.payType = [self.payType copyWithZone:zone];
- copy.teacherId = [self.teacherId copyWithZone:zone];
- copy.relationType = [self.relationType copyWithZone:zone];
- copy.userName = [self.userName copyWithZone:zone];
- copy.virtualNumber = self.virtualNumber;
- }
-
- return copy;
- }
- @end
|