Keine Beschreibung

CommentItem.m 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // CommentItem.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/6/24.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "CommentItem.h"
  9. @implementation CommentItem
  10. + (NSDictionary *)mts_mapping
  11. {
  12. return @{@"id" : mts_key(commentID),
  13. @"item_id" : mts_key(itemID),
  14. @"seller_id" : mts_key(sellerID),
  15. @"buyer_id" : mts_key(buyerID),
  16. @"buyer_nickname" : mts_key(buyerNickName),
  17. @"buyer_head_pic" : mts_key(buyerHeaderPic),
  18. @"reply_to_user_id" : mts_key(replyToUserID),
  19. @"reply_to_user_nick" : mts_key(replyToUserNickName),
  20. @"content" : mts_key(content),
  21. @"create_time" : mts_key(createTime),
  22. @"update_time" : mts_key(updateTime),
  23. @"status" : mts_key(status)
  24. };
  25. }
  26. + (BOOL)mts_shouldSetUndefinedKeys
  27. {
  28. return NO;
  29. }
  30. - (NSAttributedString *)getRealCommentTitle
  31. {
  32. NSString *currentUserID = [FKUserManager sharedManager].user.userID;
  33. NSAttributedString *attStr = nil;
  34. if (![self.replyToUserID isKindOfClass:[NSString class]] || ![self.replyToUserNickName isKindOfClass:[NSString class]] || self.replyToUserID.length == 0 || self.replyToUserNickName.length == 0) {
  35. // 不是回复
  36. NSString *finalName = self.buyerNickName;
  37. if ([self.buyerID isEqualToString:currentUserID]) finalName = @"我"; // 自己的评论
  38. attStr = [[NSAttributedString alloc]initWithString:finalName];
  39. }else{
  40. NSString *name = self.buyerNickName;
  41. NSString *replyName = self.replyToUserNickName;
  42. if ([self.buyerID isEqualToString:currentUserID]) name = @"我";
  43. if ([self.replyToUserID isEqualToString:currentUserID]) replyName = @"我";
  44. NSString *finalName = [NSString stringWithFormat:@"%@ 回复 %@", name, replyName];
  45. NSMutableAttributedString *attM = [[NSMutableAttributedString alloc]initWithString:finalName];
  46. [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(name.length + 1, 2)];
  47. attStr = attM;
  48. }
  49. return attStr;
  50. }
  51. @end