Нет описания

User.m 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // User.m
  3. // FirstLink
  4. //
  5. // Created by unicode on 14-9-30.
  6. // Copyright (c) 2014年 FirstLink. All rights reserved.
  7. //
  8. #import "User.h"
  9. @implementation User
  10. @synthesize isNew = _isNew;
  11. @synthesize headurl = _headurl;
  12. @synthesize mobile = _mobile;
  13. @synthesize nickName = _nickName;
  14. @synthesize status = _status;
  15. @synthesize level = _level;
  16. @synthesize token = _token;
  17. @synthesize userID = _userID;
  18. + (NSDictionary*)mts_mapping
  19. {
  20. return @{
  21. @"data.user.headurl": mts_key(headurl),
  22. @"data.user.mobile": mts_key(mobile),
  23. @"data.user.nickname": mts_key(nickName),
  24. @"data.user.status": mts_key(status),
  25. @"data.user.level": mts_key(level),
  26. @"data.user.token": mts_key(token),
  27. @"data.user.userid": mts_key(userID),
  28. @"data.regist_mark": mts_key(markCode),
  29. };
  30. }
  31. + (BOOL)mts_shouldSetUndefinedKeys
  32. {
  33. return NO;
  34. }
  35. - (void) encodeWithCoder:(NSCoder *)encoder {
  36. [encoder encodeObject:_isNew forKey:kIsNew];
  37. [encoder encodeObject:_headurl forKey:kHeadURL];
  38. [encoder encodeObject:_mobile forKey:kMobile];
  39. [encoder encodeObject:_nickName forKey:kNickName];
  40. [encoder encodeObject:_status forKey:kStatus];
  41. [encoder encodeObject:_level forKey:kLevel];
  42. [encoder encodeObject:_token forKey:kToken];
  43. [encoder encodeObject:_userID forKey:kUserID];
  44. [encoder encodeObject:_introduce forKey:kIntroduce];
  45. }
  46. - (id)initWithCoder:(NSCoder *)aDecoder {
  47. self = [super init];
  48. if(self) {
  49. self.isNew = [aDecoder decodeObjectForKey:kIsNew];
  50. self.headurl = [aDecoder decodeObjectForKey:kHeadURL];
  51. self.mobile = [aDecoder decodeObjectForKey:kMobile];
  52. self.nickName = [aDecoder decodeObjectForKey:kNickName];
  53. self.status = [aDecoder decodeObjectForKey:kStatus];
  54. self.level = [aDecoder decodeObjectForKey:kLevel];
  55. self.token = [aDecoder decodeObjectForKey:kToken];
  56. self.userID = [aDecoder decodeObjectForKey:kUserID];
  57. self.introduce = [aDecoder decodeObjectForKey:kIntroduce];
  58. }
  59. return self;
  60. }
  61. - (id)mutableCopyWithZone:(NSZone *)zone {
  62. User *copy = [[User alloc] init];
  63. copy.isNew = [self.isNew mutableCopy];
  64. copy.headurl = [self.headurl mutableCopy];
  65. copy.mobile = [self.mobile mutableCopy];
  66. copy.nickName = [self.nickName mutableCopy];
  67. copy.status = [self.status mutableCopy];
  68. copy.level = [self.level mutableCopy];
  69. copy.token = [self.token mutableCopy];
  70. copy.umengToken = [self.umengToken mutableCopy];
  71. copy.userID = [self.userID mutableCopy];
  72. copy.introduce = [self.introduce mutableCopy];
  73. copy.lastLoginType = self.lastLoginType;
  74. return copy;
  75. }
  76. #pragma mark - Business Method
  77. - (BOOL)isVIP {
  78. if (self.level.intValue >= 2) {
  79. return TRUE;
  80. }
  81. return FALSE;
  82. }
  83. - (BOOL)isVipWithDiscount {
  84. if (self.level.intValue == 2) {
  85. return TRUE;
  86. }
  87. return FALSE;
  88. }
  89. @end