|
@@ -0,0 +1,162 @@
|
|
|
+//
|
|
|
+// CoursePargramListModel.m
|
|
|
+//
|
|
|
+// Created by Steven on 2024/11/20
|
|
|
+// Copyright (c) 2024 __MyCompanyName__. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "CoursePargramListModel.h"
|
|
|
+
|
|
|
+
|
|
|
+NSString *const kCoursePargramListModelCreateTime = @"createTime";
|
|
|
+NSString *const kCoursePargramListModelId = @"id";
|
|
|
+NSString *const kCoursePargramListModelUpdateTime = @"updateTime";
|
|
|
+NSString *const kCoursePargramListModelSubjectPrice = @"subjectPrice";
|
|
|
+NSString *const kCoursePargramListModelSubjectId = @"subjectId";
|
|
|
+NSString *const kCoursePargramListModelSubjectName = @"subjectName";
|
|
|
+NSString *const kCoursePargramListModelCourseMinutes = @"courseMinutes";
|
|
|
+NSString *const kCoursePargramListModelFreeMinutes = @"freeMinutes";
|
|
|
+NSString *const kCoursePargramListModelTeacherId = @"teacherId";
|
|
|
+NSString *const kCoursePargramListModelCourseType = @"courseType";
|
|
|
+
|
|
|
+
|
|
|
+@interface CoursePargramListModel ()
|
|
|
+
|
|
|
+- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation CoursePargramListModel
|
|
|
+
|
|
|
+@synthesize createTime = _createTime;
|
|
|
+@synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
|
|
|
+@synthesize updateTime = _updateTime;
|
|
|
+@synthesize subjectPrice = _subjectPrice;
|
|
|
+@synthesize subjectId = _subjectId;
|
|
|
+@synthesize subjectName = _subjectName;
|
|
|
+@synthesize courseMinutes = _courseMinutes;
|
|
|
+@synthesize freeMinutes = _freeMinutes;
|
|
|
+@synthesize teacherId = _teacherId;
|
|
|
+@synthesize courseType = _courseType;
|
|
|
+
|
|
|
+
|
|
|
++ (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.createTime = [self objectOrNilForKey:kCoursePargramListModelCreateTime fromDictionary:dict];
|
|
|
+ self.internalBaseClassIdentifier = [self objectOrNilForKey:kCoursePargramListModelId fromDictionary:dict];
|
|
|
+ self.updateTime = [self objectOrNilForKey:kCoursePargramListModelUpdateTime fromDictionary:dict];
|
|
|
+ self.subjectPrice = [[self objectOrNilForKey:kCoursePargramListModelSubjectPrice fromDictionary:dict] doubleValue];
|
|
|
+ self.subjectId = [self objectOrNilForKey:kCoursePargramListModelSubjectId fromDictionary:dict];
|
|
|
+ self.subjectName = [self objectOrNilForKey:kCoursePargramListModelSubjectName fromDictionary:dict];
|
|
|
+ self.courseMinutes = [[self objectOrNilForKey:kCoursePargramListModelCourseMinutes fromDictionary:dict] doubleValue];
|
|
|
+ self.freeMinutes = [[self objectOrNilForKey:kCoursePargramListModelFreeMinutes fromDictionary:dict] doubleValue];
|
|
|
+ self.teacherId = [self objectOrNilForKey:kCoursePargramListModelTeacherId fromDictionary:dict];
|
|
|
+ self.courseType = [self objectOrNilForKey:kCoursePargramListModelCourseType fromDictionary:dict];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return self;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (NSDictionary *)dictionaryRepresentation
|
|
|
+{
|
|
|
+ NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
|
|
|
+ [mutableDict setValue:self.createTime forKey:kCoursePargramListModelCreateTime];
|
|
|
+ [mutableDict setValue:self.internalBaseClassIdentifier forKey:kCoursePargramListModelId];
|
|
|
+ [mutableDict setValue:self.updateTime forKey:kCoursePargramListModelUpdateTime];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.subjectPrice] forKey:kCoursePargramListModelSubjectPrice];
|
|
|
+ [mutableDict setValue:self.subjectId forKey:kCoursePargramListModelSubjectId];
|
|
|
+ [mutableDict setValue:self.subjectName forKey:kCoursePargramListModelSubjectName];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.courseMinutes] forKey:kCoursePargramListModelCourseMinutes];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.freeMinutes] forKey:kCoursePargramListModelFreeMinutes];
|
|
|
+ [mutableDict setValue:self.teacherId forKey:kCoursePargramListModelTeacherId];
|
|
|
+ [mutableDict setValue:self.courseType forKey:kCoursePargramListModelCourseType];
|
|
|
+
|
|
|
+ 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.createTime = [aDecoder decodeObjectForKey:kCoursePargramListModelCreateTime];
|
|
|
+ self.internalBaseClassIdentifier = [aDecoder decodeObjectForKey:kCoursePargramListModelId];
|
|
|
+ self.updateTime = [aDecoder decodeObjectForKey:kCoursePargramListModelUpdateTime];
|
|
|
+ self.subjectPrice = [aDecoder decodeDoubleForKey:kCoursePargramListModelSubjectPrice];
|
|
|
+ self.subjectId = [aDecoder decodeObjectForKey:kCoursePargramListModelSubjectId];
|
|
|
+ self.subjectName = [aDecoder decodeObjectForKey:kCoursePargramListModelSubjectName];
|
|
|
+ self.courseMinutes = [aDecoder decodeDoubleForKey:kCoursePargramListModelCourseMinutes];
|
|
|
+ self.freeMinutes = [aDecoder decodeDoubleForKey:kCoursePargramListModelFreeMinutes];
|
|
|
+ self.teacherId = [aDecoder decodeObjectForKey:kCoursePargramListModelTeacherId];
|
|
|
+ self.courseType = [aDecoder decodeObjectForKey:kCoursePargramListModelCourseType];
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
|
+{
|
|
|
+
|
|
|
+ [aCoder encodeObject:_createTime forKey:kCoursePargramListModelCreateTime];
|
|
|
+ [aCoder encodeObject:_internalBaseClassIdentifier forKey:kCoursePargramListModelId];
|
|
|
+ [aCoder encodeObject:_updateTime forKey:kCoursePargramListModelUpdateTime];
|
|
|
+ [aCoder encodeDouble:_subjectPrice forKey:kCoursePargramListModelSubjectPrice];
|
|
|
+ [aCoder encodeObject:_subjectId forKey:kCoursePargramListModelSubjectId];
|
|
|
+ [aCoder encodeObject:_subjectName forKey:kCoursePargramListModelSubjectName];
|
|
|
+ [aCoder encodeDouble:_courseMinutes forKey:kCoursePargramListModelCourseMinutes];
|
|
|
+ [aCoder encodeDouble:_freeMinutes forKey:kCoursePargramListModelFreeMinutes];
|
|
|
+ [aCoder encodeObject:_teacherId forKey:kCoursePargramListModelTeacherId];
|
|
|
+ [aCoder encodeObject:_courseType forKey:kCoursePargramListModelCourseType];
|
|
|
+}
|
|
|
+
|
|
|
+- (id)copyWithZone:(NSZone *)zone
|
|
|
+{
|
|
|
+ CoursePargramListModel *copy = [[CoursePargramListModel alloc] init];
|
|
|
+
|
|
|
+ if (copy) {
|
|
|
+
|
|
|
+ copy.createTime = [self.createTime copyWithZone:zone];
|
|
|
+ copy.internalBaseClassIdentifier = [self.internalBaseClassIdentifier copyWithZone:zone];
|
|
|
+ copy.updateTime = [self.updateTime copyWithZone:zone];
|
|
|
+ copy.subjectPrice = self.subjectPrice;
|
|
|
+ copy.subjectId = [self.subjectId copyWithZone:zone];
|
|
|
+ copy.subjectName = [self.subjectName copyWithZone:zone];
|
|
|
+ copy.courseMinutes = self.courseMinutes;
|
|
|
+ copy.freeMinutes = self.freeMinutes;
|
|
|
+ copy.teacherId = [self.teacherId copyWithZone:zone];
|
|
|
+ copy.courseType = [self.courseType copyWithZone:zone];
|
|
|
+ }
|
|
|
+
|
|
|
+ return copy;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|