12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // CommentItem.m
- // FirstLink
- //
- // Created by jack on 15/6/24.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "CommentItem.h"
- @implementation CommentItem
- + (NSDictionary *)mts_mapping
- {
- return @{@"id" : mts_key(commentID),
- @"item_id" : mts_key(itemID),
- @"seller_id" : mts_key(sellerID),
- @"buyer_id" : mts_key(buyerID),
- @"buyer_nickname" : mts_key(buyerNickName),
- @"buyer_head_pic" : mts_key(buyerHeaderPic),
- @"reply_to_user_id" : mts_key(replyToUserID),
- @"reply_to_user_nick" : mts_key(replyToUserNickName),
- @"content" : mts_key(content),
- @"create_time" : mts_key(createTime),
- @"update_time" : mts_key(updateTime),
- @"status" : mts_key(status)
- };
- }
- + (BOOL)mts_shouldSetUndefinedKeys
- {
- return NO;
- }
- - (NSAttributedString *)getRealCommentTitle
- {
- NSString *currentUserID = [FKUserManager sharedManager].user.userID;
- NSAttributedString *attStr = nil;
-
- if (![self.replyToUserID isKindOfClass:[NSString class]] || ![self.replyToUserNickName isKindOfClass:[NSString class]] || self.replyToUserID.length == 0 || self.replyToUserNickName.length == 0) {
- // 不是回复
- NSString *finalName = self.buyerNickName;
- if ([self.buyerID isEqualToString:currentUserID]) finalName = @"我"; // 自己的评论
- attStr = [[NSAttributedString alloc]initWithString:finalName];
- }else{
- NSString *name = self.buyerNickName;
- NSString *replyName = self.replyToUserNickName;
- if ([self.buyerID isEqualToString:currentUserID]) name = @"我";
- if ([self.replyToUserID isEqualToString:currentUserID]) replyName = @"我";
- NSString *finalName = [NSString stringWithFormat:@"%@ 回复 %@", name, replyName];
- NSMutableAttributedString *attM = [[NSMutableAttributedString alloc]initWithString:finalName];
- [attM addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(name.length + 1, 2)];
- attStr = attM;
- }
- return attStr;
- }
- @end
|