StockingModel.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // StockingModel.m
  3. // IBOSS
  4. //
  5. // Created by apple on 2017/5/17.
  6. // Copyright © 2017年 沈阳东科云信软件有限公司. All rights reserved.
  7. //
  8. // 功能描述:盘点模型
  9. //
  10. #import "StockingModel.h"
  11. #import "DateFormat.h"
  12. @implementation StockingModel
  13. /*!
  14. * 1.该方法是 `字典里的属性Key` 和 `要转化为模型里的属性名` 不一样 而重写的
  15. * 前:模型的属性 后:字典里的属性
  16. */
  17. + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
  18. return @{@"code":@"Code",
  19. @"onlyCode":@"OnlyCode",
  20. @"specification":@"Specification",
  21. @"colorNumber":@"ColorNumber",
  22. @"gradeName":@"GradeName",
  23. @"warehouseName":@"WarehouseName",
  24. @"positionNumber":@"PositionNumber",
  25. @"stockingNo":@"CheckNo",
  26. @"stockingID":@"DetailID",
  27. @"codeID":@"CodeID",
  28. @"inventoryID":@"InventoryID",
  29. @"quantity":@"InventoryQuantity",
  30. @"balanceQuantity":@"BalanceQuantity",
  31. @"createUser":@"UserName",
  32. @"createTime":@"CreateTime"};
  33. }
  34. /*!
  35. * 2. 下面的两个方法 `字典里值`与`模型的值`类型不一样`需要转换`而重写的方法
  36. * NSDate *time dic[@"t"]是double类型的的秒数
  37. */
  38. /// Dic -> model
  39. - (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic {
  40. DateFormat *d = [[DateFormat alloc] init];
  41. self.stockingID = [[dic objectForKey:@"DetailID"]stringValue];
  42. self.inventoryID = [[dic objectForKey:@"InventoryID"]stringValue];
  43. self.codeID = [[dic objectForKey:@"CodeID"]stringValue];
  44. self.quantity = [[dic objectForKey:@"InventoryQuantity"] stringValue];
  45. self.balanceQuantity = [[dic objectForKey:@"BalanceQuantity"] stringValue];
  46. self.createTime = [d dateFormat:[dic objectForKey:@"CreateTime"]];
  47. return YES;
  48. }
  49. /// model -> Dic
  50. - (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic {
  51. //dic[@"t"] = @([self.time timeIntervalSince1970] * 1000).description;
  52. return YES;
  53. }
  54. @end