|
@@ -0,0 +1,250 @@
|
|
|
+//
|
|
|
+// GroupAlbumModel.m
|
|
|
+//
|
|
|
+// Created by Steven on 2024/4/15
|
|
|
+// Copyright (c) 2024 __MyCompanyName__. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+#import "GroupAlbumModel.h"
|
|
|
+
|
|
|
+
|
|
|
+NSString *const kGroupAlbumModelOriginalPrice = @"originalPrice";
|
|
|
+NSString *const kGroupAlbumModelTenantGroupId = @"tenantGroupId";
|
|
|
+NSString *const kGroupAlbumModelStatus = @"status";
|
|
|
+NSString *const kGroupAlbumModelEnsembleCounts = @"ensembleCounts";
|
|
|
+NSString *const kGroupAlbumModelSubjectCounts = @"subjectCounts";
|
|
|
+NSString *const kGroupAlbumModelMusicNum = @"musicNum";
|
|
|
+NSString *const kGroupAlbumModelSubjectTypes = @"subjectTypes";
|
|
|
+NSString *const kGroupAlbumModelBuyedTimes = @"buyedTimes";
|
|
|
+NSString *const kGroupAlbumModelPurchasePeriod = @"purchasePeriod";
|
|
|
+NSString *const kGroupAlbumModelCoverImg = @"coverImg";
|
|
|
+NSString *const kGroupAlbumModelPurchaseJson = @"purchaseJson";
|
|
|
+NSString *const kGroupAlbumModelPurchaseNum = @"purchaseNum";
|
|
|
+NSString *const kGroupAlbumModelTenantGroupAlbumId = @"tenantGroupAlbumId";
|
|
|
+NSString *const kGroupAlbumModelBuyTimesFlag = @"buyTimesFlag";
|
|
|
+NSString *const kGroupAlbumModelName = @"name";
|
|
|
+NSString *const kGroupAlbumModelId = @"id";
|
|
|
+NSString *const kGroupAlbumModelBuyTimes = @"buyTimes";
|
|
|
+NSString *const kGroupAlbumModelDescribe = @"describe";
|
|
|
+NSString *const kGroupAlbumModelMusicCounts = @"musicCounts";
|
|
|
+NSString *const kGroupAlbumModelActualPrice = @"actualPrice";
|
|
|
+NSString *const kGroupAlbumModelPurchaseTypes = @"purchaseTypes";
|
|
|
+NSString *const kGroupAlbumModelCoursewareCounts = @"coursewareCounts";
|
|
|
+NSString *const kGroupAlbumModelExpireTime = @"expireTime";
|
|
|
+
|
|
|
+
|
|
|
+@interface GroupAlbumModel ()
|
|
|
+
|
|
|
+- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation GroupAlbumModel
|
|
|
+
|
|
|
+@synthesize originalPrice = _originalPrice;
|
|
|
+@synthesize tenantGroupId = _tenantGroupId;
|
|
|
+@synthesize status = _status;
|
|
|
+@synthesize ensembleCounts = _ensembleCounts;
|
|
|
+@synthesize subjectCounts = _subjectCounts;
|
|
|
+@synthesize musicNum = _musicNum;
|
|
|
+@synthesize subjectTypes = _subjectTypes;
|
|
|
+@synthesize buyedTimes = _buyedTimes;
|
|
|
+@synthesize purchasePeriod = _purchasePeriod;
|
|
|
+@synthesize coverImg = _coverImg;
|
|
|
+@synthesize purchaseJson = _purchaseJson;
|
|
|
+@synthesize purchaseNum = _purchaseNum;
|
|
|
+@synthesize tenantGroupAlbumId = _tenantGroupAlbumId;
|
|
|
+@synthesize buyTimesFlag = _buyTimesFlag;
|
|
|
+@synthesize name = _name;
|
|
|
+@synthesize internalBaseClassIdentifier = _internalBaseClassIdentifier;
|
|
|
+@synthesize buyTimes = _buyTimes;
|
|
|
+@synthesize describe = _describe;
|
|
|
+@synthesize musicCounts = _musicCounts;
|
|
|
+@synthesize actualPrice = _actualPrice;
|
|
|
+@synthesize purchaseTypes = _purchaseTypes;
|
|
|
+@synthesize coursewareCounts = _coursewareCounts;
|
|
|
+@synthesize expireTime = _expireTime;
|
|
|
+
|
|
|
++ (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.originalPrice = [[self objectOrNilForKey:kGroupAlbumModelOriginalPrice fromDictionary:dict] doubleValue];
|
|
|
+ self.tenantGroupId = [self objectOrNilForKey:kGroupAlbumModelTenantGroupId fromDictionary:dict];
|
|
|
+ self.status = [[self objectOrNilForKey:kGroupAlbumModelStatus fromDictionary:dict] boolValue];
|
|
|
+ self.ensembleCounts = [[self objectOrNilForKey:kGroupAlbumModelEnsembleCounts fromDictionary:dict] integerValue];
|
|
|
+ self.subjectCounts = [[self objectOrNilForKey:kGroupAlbumModelSubjectCounts fromDictionary:dict] integerValue];
|
|
|
+ self.musicNum = [[self objectOrNilForKey:kGroupAlbumModelMusicNum fromDictionary:dict] integerValue];
|
|
|
+ self.subjectTypes = [self objectOrNilForKey:kGroupAlbumModelSubjectTypes fromDictionary:dict];
|
|
|
+ self.buyedTimes = [[self objectOrNilForKey:kGroupAlbumModelBuyedTimes fromDictionary:dict] integerValue];
|
|
|
+ self.purchasePeriod = [self objectOrNilForKey:kGroupAlbumModelPurchasePeriod fromDictionary:dict];
|
|
|
+ self.coverImg = [self objectOrNilForKey:kGroupAlbumModelCoverImg fromDictionary:dict];
|
|
|
+ self.purchaseJson = [self objectOrNilForKey:kGroupAlbumModelPurchaseJson fromDictionary:dict];
|
|
|
+ self.purchaseNum = [[self objectOrNilForKey:kGroupAlbumModelPurchaseNum fromDictionary:dict] integerValue];
|
|
|
+ self.tenantGroupAlbumId = [self objectOrNilForKey:kGroupAlbumModelTenantGroupAlbumId fromDictionary:dict];
|
|
|
+ self.buyTimesFlag = [[self objectOrNilForKey:kGroupAlbumModelBuyTimesFlag fromDictionary:dict] boolValue];
|
|
|
+ self.name = [self objectOrNilForKey:kGroupAlbumModelName fromDictionary:dict];
|
|
|
+ self.internalBaseClassIdentifier = [self objectOrNilForKey:kGroupAlbumModelId fromDictionary:dict];
|
|
|
+ self.buyTimes = [[self objectOrNilForKey:kGroupAlbumModelBuyTimes fromDictionary:dict] integerValue];
|
|
|
+ self.describe = [self objectOrNilForKey:kGroupAlbumModelDescribe fromDictionary:dict];
|
|
|
+ self.musicCounts = [[self objectOrNilForKey:kGroupAlbumModelMusicCounts fromDictionary:dict] integerValue];
|
|
|
+ self.actualPrice = [[self objectOrNilForKey:kGroupAlbumModelActualPrice fromDictionary:dict] doubleValue];
|
|
|
+ self.purchaseTypes = [self objectOrNilForKey:kGroupAlbumModelPurchaseTypes fromDictionary:dict];
|
|
|
+ self.coursewareCounts = [[self objectOrNilForKey:kGroupAlbumModelCoursewareCounts fromDictionary:dict] integerValue];
|
|
|
+ self.expireTime = [self objectOrNilForKey:kGroupAlbumModelExpireTime fromDictionary:dict];
|
|
|
+ }
|
|
|
+
|
|
|
+ return self;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (NSDictionary *)dictionaryRepresentation
|
|
|
+{
|
|
|
+ NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.originalPrice] forKey:kGroupAlbumModelOriginalPrice];
|
|
|
+ [mutableDict setValue:self.tenantGroupId forKey:kGroupAlbumModelTenantGroupId];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithBool:self.status] forKey:kGroupAlbumModelStatus];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.ensembleCounts] forKey:kGroupAlbumModelEnsembleCounts];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.subjectCounts] forKey:kGroupAlbumModelSubjectCounts];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.musicNum] forKey:kGroupAlbumModelMusicNum];
|
|
|
+ [mutableDict setValue:self.subjectTypes forKey:kGroupAlbumModelSubjectTypes];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.buyedTimes] forKey:kGroupAlbumModelBuyedTimes];
|
|
|
+ [mutableDict setValue:self.purchasePeriod forKey:kGroupAlbumModelPurchasePeriod];
|
|
|
+ [mutableDict setValue:self.coverImg forKey:kGroupAlbumModelCoverImg];
|
|
|
+ [mutableDict setValue:self.purchaseJson forKey:kGroupAlbumModelPurchaseJson];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.purchaseNum] forKey:kGroupAlbumModelPurchaseNum];
|
|
|
+ [mutableDict setValue:self.tenantGroupAlbumId forKey:kGroupAlbumModelTenantGroupAlbumId];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithBool:self.buyTimesFlag] forKey:kGroupAlbumModelBuyTimesFlag];
|
|
|
+ [mutableDict setValue:self.name forKey:kGroupAlbumModelName];
|
|
|
+ [mutableDict setValue:self.internalBaseClassIdentifier forKey:kGroupAlbumModelId];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.buyTimes] forKey:kGroupAlbumModelBuyTimes];
|
|
|
+ [mutableDict setValue:self.describe forKey:kGroupAlbumModelDescribe];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.musicCounts] forKey:kGroupAlbumModelMusicCounts];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithDouble:self.actualPrice] forKey:kGroupAlbumModelActualPrice];
|
|
|
+ [mutableDict setValue:self.purchaseTypes forKey:kGroupAlbumModelPurchaseTypes];
|
|
|
+ [mutableDict setValue:[NSNumber numberWithInteger:self.coursewareCounts] forKey:kGroupAlbumModelCoursewareCounts];
|
|
|
+ [mutableDict setValue:self.expireTime forKey:kGroupAlbumModelExpireTime];
|
|
|
+ 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.originalPrice = [aDecoder decodeDoubleForKey:kGroupAlbumModelOriginalPrice];
|
|
|
+ self.tenantGroupId = [aDecoder decodeObjectForKey:kGroupAlbumModelTenantGroupId];
|
|
|
+ self.status = [aDecoder decodeBoolForKey:kGroupAlbumModelStatus];
|
|
|
+ self.ensembleCounts = [aDecoder decodeIntegerForKey:kGroupAlbumModelEnsembleCounts];
|
|
|
+ self.subjectCounts = [aDecoder decodeIntegerForKey:kGroupAlbumModelSubjectCounts];
|
|
|
+ self.musicNum = [aDecoder decodeIntegerForKey:kGroupAlbumModelMusicNum];
|
|
|
+ self.subjectTypes = [aDecoder decodeObjectForKey:kGroupAlbumModelSubjectTypes];
|
|
|
+ self.buyedTimes = [aDecoder decodeIntegerForKey:kGroupAlbumModelBuyedTimes];
|
|
|
+ self.purchasePeriod = [aDecoder decodeObjectForKey:kGroupAlbumModelPurchasePeriod];
|
|
|
+ self.coverImg = [aDecoder decodeObjectForKey:kGroupAlbumModelCoverImg];
|
|
|
+ self.purchaseJson = [aDecoder decodeObjectForKey:kGroupAlbumModelPurchaseJson];
|
|
|
+ self.purchaseNum = [aDecoder decodeIntegerForKey:kGroupAlbumModelPurchaseNum];
|
|
|
+ self.tenantGroupAlbumId = [aDecoder decodeObjectForKey:kGroupAlbumModelTenantGroupAlbumId];
|
|
|
+ self.buyTimesFlag = [aDecoder decodeBoolForKey:kGroupAlbumModelBuyTimesFlag];
|
|
|
+ self.name = [aDecoder decodeObjectForKey:kGroupAlbumModelName];
|
|
|
+ self.internalBaseClassIdentifier = [aDecoder decodeObjectForKey:kGroupAlbumModelId];
|
|
|
+ self.buyTimes = [aDecoder decodeIntegerForKey:kGroupAlbumModelBuyTimes];
|
|
|
+ self.describe = [aDecoder decodeObjectForKey:kGroupAlbumModelDescribe];
|
|
|
+ self.musicCounts = [aDecoder decodeIntegerForKey:kGroupAlbumModelMusicCounts];
|
|
|
+ self.actualPrice = [aDecoder decodeDoubleForKey:kGroupAlbumModelActualPrice];
|
|
|
+ self.purchaseTypes = [aDecoder decodeObjectForKey:kGroupAlbumModelPurchaseTypes];
|
|
|
+ self.coursewareCounts = [aDecoder decodeIntegerForKey:kGroupAlbumModelCoursewareCounts];
|
|
|
+ self.expireTime = [aDecoder decodeObjectForKey:kGroupAlbumModelExpireTime];
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
|
+{
|
|
|
+
|
|
|
+ [aCoder encodeDouble:_originalPrice forKey:kGroupAlbumModelOriginalPrice];
|
|
|
+ [aCoder encodeObject:_tenantGroupId forKey:kGroupAlbumModelTenantGroupId];
|
|
|
+ [aCoder encodeBool:_status forKey:kGroupAlbumModelStatus];
|
|
|
+ [aCoder encodeInteger:_ensembleCounts forKey:kGroupAlbumModelEnsembleCounts];
|
|
|
+ [aCoder encodeInteger:_subjectCounts forKey:kGroupAlbumModelSubjectCounts];
|
|
|
+ [aCoder encodeInteger:_musicNum forKey:kGroupAlbumModelMusicNum];
|
|
|
+ [aCoder encodeObject:_subjectTypes forKey:kGroupAlbumModelSubjectTypes];
|
|
|
+ [aCoder encodeInteger:_buyedTimes forKey:kGroupAlbumModelBuyedTimes];
|
|
|
+ [aCoder encodeObject:_purchasePeriod forKey:kGroupAlbumModelPurchasePeriod];
|
|
|
+ [aCoder encodeObject:_coverImg forKey:kGroupAlbumModelCoverImg];
|
|
|
+ [aCoder encodeObject:_purchaseJson forKey:kGroupAlbumModelPurchaseJson];
|
|
|
+ [aCoder encodeInteger:_purchaseNum forKey:kGroupAlbumModelPurchaseNum];
|
|
|
+ [aCoder encodeObject:_tenantGroupAlbumId forKey:kGroupAlbumModelTenantGroupAlbumId];
|
|
|
+ [aCoder encodeBool:_buyTimesFlag forKey:kGroupAlbumModelBuyTimesFlag];
|
|
|
+ [aCoder encodeObject:_name forKey:kGroupAlbumModelName];
|
|
|
+ [aCoder encodeObject:_internalBaseClassIdentifier forKey:kGroupAlbumModelId];
|
|
|
+ [aCoder encodeInteger:_buyTimes forKey:kGroupAlbumModelBuyTimes];
|
|
|
+ [aCoder encodeObject:_describe forKey:kGroupAlbumModelDescribe];
|
|
|
+ [aCoder encodeInteger:_musicCounts forKey:kGroupAlbumModelMusicCounts];
|
|
|
+ [aCoder encodeDouble:_actualPrice forKey:kGroupAlbumModelActualPrice];
|
|
|
+ [aCoder encodeObject:_purchaseTypes forKey:kGroupAlbumModelPurchaseTypes];
|
|
|
+ [aCoder encodeInteger:_coursewareCounts forKey:kGroupAlbumModelCoursewareCounts];
|
|
|
+ [aCoder encodeObject:_expireTime forKey:kGroupAlbumModelExpireTime];
|
|
|
+}
|
|
|
+
|
|
|
+- (id)copyWithZone:(NSZone *)zone
|
|
|
+{
|
|
|
+ GroupAlbumModel *copy = [[GroupAlbumModel alloc] init];
|
|
|
+
|
|
|
+ if (copy) {
|
|
|
+
|
|
|
+ copy.originalPrice = self.originalPrice;
|
|
|
+ copy.tenantGroupId = [self.tenantGroupId copyWithZone:zone];
|
|
|
+ copy.status = self.status;
|
|
|
+ copy.ensembleCounts = self.ensembleCounts;
|
|
|
+ copy.subjectCounts = self.subjectCounts;
|
|
|
+ copy.musicNum = self.musicNum;
|
|
|
+ copy.subjectTypes = [self.subjectTypes copyWithZone:zone];
|
|
|
+ copy.buyedTimes = self.buyedTimes;
|
|
|
+ copy.purchasePeriod = [self.purchasePeriod copyWithZone:zone];
|
|
|
+ copy.coverImg = [self.coverImg copyWithZone:zone];
|
|
|
+ copy.purchaseJson = [self.purchaseJson copyWithZone:zone];
|
|
|
+ copy.purchaseNum = self.purchaseNum;
|
|
|
+ copy.tenantGroupAlbumId = [self.tenantGroupAlbumId copyWithZone:zone];
|
|
|
+ copy.buyTimesFlag = self.buyTimesFlag;
|
|
|
+ copy.name = [self.name copyWithZone:zone];
|
|
|
+ copy.internalBaseClassIdentifier = [self.internalBaseClassIdentifier copyWithZone:zone];
|
|
|
+ copy.buyTimes = self.buyTimes;
|
|
|
+ copy.describe = [self.describe copyWithZone:zone];
|
|
|
+ copy.musicCounts = self.musicCounts;
|
|
|
+ copy.actualPrice = self.actualPrice;
|
|
|
+ copy.purchaseTypes = [self.purchaseTypes copyWithZone:zone];
|
|
|
+ copy.coursewareCounts = self.coursewareCounts;
|
|
|
+ copy.expireTime = [self.expireTime copyWithZone:zone];
|
|
|
+ }
|
|
|
+
|
|
|
+ return copy;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|