No Description

FKWantBuyReform.m 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // FKWantBuyReform.m
  3. // FirstLink
  4. //
  5. // Created by 施昌鹏 on 16/8/18.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKWantBuyReform.h"
  9. #import "FKWantBuyItem.h"
  10. #import "FKWantBuyProItem.h"
  11. @implementation FKWantBuyReform
  12. +(NSString *)pareserStorageNumber:(NSDictionary *)dict {
  13. if ([dict[@"data"][@"list"] isKindOfClass:[NSDictionary class]]) {
  14. return [NSString stringWithFormat:@"%@",dict[@"data"][@"list"][@"storage_number"]];
  15. }
  16. return nil;
  17. }
  18. + (NSString *)parseStatus:(NSDictionary *)dict targetURL:(NSString *)targetURL {
  19. if ([dict[@"data"] isKindOfClass:[NSDictionary class]] && targetURL) {
  20. NSURL *url = [NSURL URLWithString:targetURL];
  21. if (url) {
  22. for (NSString *key in [dict[@"data"] allKeys]) {
  23. if ([key containsString:url.path]) {
  24. NSNumber *number = dict[@"data"][key];
  25. return [NSString stringWithFormat:@"%@", number];
  26. }
  27. }
  28. }
  29. }
  30. return nil;
  31. }
  32. + (NSInteger)pareserTotalCount:(NSDictionary *)dict {
  33. if ([dict[@"data"][@"pager"] isKindOfClass:[NSDictionary class]]) {
  34. NSNumber *number = dict[@"data"][@"pager"][@"total"];
  35. if ([number isKindOfClass:[NSNumber class]]) {
  36. return number.integerValue;
  37. }
  38. }
  39. return 0;
  40. }
  41. +(NSMutableArray *)parserWantBuyDetailWithDict:(NSDictionary *)dict {
  42. if (![dict isKindOfClass:[NSDictionary class]]) return nil;
  43. NSArray *dataArray = dict[@"data"][@"list"];
  44. if ([dataArray isKindOfClass:[NSArray class]] && dataArray.count > 0) {
  45. NSMutableArray *arrayM = [NSMutableArray arrayWithCapacity:dataArray.count];
  46. for (NSDictionary *itemDict in dataArray) {
  47. FKWantBuyItem *item = [[FKWantBuyItem alloc] init];
  48. [item mts_setValuesForKeysWithDictionary:itemDict];
  49. [arrayM addObject:item];
  50. }
  51. return arrayM;
  52. }
  53. return nil;
  54. }
  55. @end