// // StockingModel.m // IBOSS // // Created by apple on 2017/5/17. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved. // // 功能描述:盘点模型 // #import "StockingModel.h" #import "DateFormat.h" @implementation StockingModel /*! * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的 * 前:模型的属性 后:字典里的属性 */ + (nullable NSDictionary *)modelCustomPropertyMapper{ return @{@"code":@"Code", @"onlyCode":@"OnlyCode", @"specification":@"Specification", @"colorNumber":@"ColorNumber", @"gradeName":@"GradeName", @"warehouseName":@"WarehouseName", @"positionNumber":@"PositionNumber", @"stockingNo":@"CheckNo", @"stockingID":@"DetailID", @"codeID":@"CodeID", @"inventoryID":@"InventoryID", @"quantity":@"InventoryQuantity", @"balanceQuantity":@"BalanceQuantity", @"createUser":@"UserName", @"createTime":@"CreateTime"}; } /*! * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法 * NSDate *time dic[@"t"]是double类型的的秒数 */ /// Dic -> model - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic { DateFormat *d = [[DateFormat alloc] init]; self.stockingID = [[dic objectForKey:@"DetailID"]stringValue]; self.inventoryID = [[dic objectForKey:@"InventoryID"]stringValue]; self.codeID = [[dic objectForKey:@"CodeID"]stringValue]; self.quantity = [[dic objectForKey:@"InventoryQuantity"] stringValue]; self.balanceQuantity = [[dic objectForKey:@"BalanceQuantity"] stringValue]; self.createTime = [d dateFormat:[dic objectForKey:@"CreateTime"]]; return YES; } /// model -> Dic - (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic { //dic[@"t"] = @([self.time timeIntervalSince1970] * 1000).description; return YES; } @end