| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287 |
- //
- // GroupDBMgr.m
- // zhuxun
- //
- // Created by winsoft on 17/4/24.
- //
- //
- #import "GroupDBMgr.h"
- #import "DBOperation.h"
- //#import "HttpManager.h"
- //#import "GroupMsgRSMgrCenter.h"
- //#import "MessageHandleCenter.h"
- #define MuiltTextPicExpression @"([\\s\\S]*?)\\[image\\-src=\"([a-zA-Z0-9]{32})\"\\]([\\s\\S]*?)"
- #define TeamShareExpression @"\\<TeamShare\\>(.*)\\<\\/TeamShare\\>"
- @interface GroupDBMgr()
- /**
- * addrbook
- */
- @property (nonatomic , strong) NSMutableDictionary *allUserDict;
- /**
- * usergroupEntity
- */
- @property (nonatomic , strong) NSMutableDictionary *allUserGroupsDict;
- /**
- * recentEntiy
- */
- @property (nonatomic , strong) NSMutableDictionary *allUserRecentsDict;
- @end
- @implementation GroupDBMgr
- + (instancetype)shareInstance
- {
- static GroupDBMgr * groupDBMgr;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- groupDBMgr = [[GroupDBMgr alloc] init];
-
- });
- return groupDBMgr;
- }
- - (NSString *)getMessageID
- {
- NSString *uuid = [[[[NSUUID UUID]UUIDString]stringByReplacingOccurrencesOfString:@"-" withString:@""]lowercaseString];
- return uuid;
- }
- - (NSMutableDictionary *)allUserDict
- {
-
- if (!_allUserDict) {
- _allUserDict = [NSMutableDictionary dictionary];
- }
-
- return _allUserDict;
- }
- - (NSMutableDictionary *)allUserRecentsDict
- {
- if (!_allUserRecentsDict) {
- _allUserRecentsDict = [NSMutableDictionary dictionary];
- }
-
- return _allUserRecentsDict;
- }
- - (NSMutableDictionary *)allUserGroupsDict
- {
- if (!_allUserGroupsDict) {
- _allUserGroupsDict = [NSMutableDictionary dictionary];
- }
-
- return _allUserGroupsDict;
- }
- //- (void)getGroupEntityWithGroupID:(NSString *)groupID resultGroupEntityBlock:(void(^)(UserGroupEntity *userGroupEntity))resultGroupEntityBlock
- //{
- // __block UserGroupEntity *userGroupEntity = [self.allUserGroupsDict objectForKey:groupID];
- //
- // __weak typeof(self)weakSelf = self;
- //
- // if (!userGroupEntity) {
- // //此类型的待移至dboperation.
- // userGroupEntity = [UserGroupEntity findUserGroupEntityWithGroupID:groupID];
- //
- // if (!userGroupEntity) {
- //
- //
- // [[GroupMsgRSMgrCenter shareInstance]getGroupDetailWithGroupID:groupID withResultBlock:^(BOOL result, NSString *uuid, NSDictionary *message) {
- //
- //
- // userGroupEntity = [weakSelf createGroupEntityWithGroupParams:message[@"group"] resultBlock:^{
- //
- // resultGroupEntityBlock(userGroupEntity);
- //
- // }];
- //
- //
- // }];
- //
- // }
- // }
- //
- // if (userGroupEntity) {
- // resultGroupEntityBlock(userGroupEntity);
- // }
- //
- //}
- //- (void)getMyAllGroupsWithResultGroupsBlock:(void(^)(NSArray *))groups
- //{
- // NSArray *array = nil;
- //
- // if (self.allUserGroupsDict.allValues.count) {
- // array = self.allUserGroupsDict.allValues;
- // }else{
- //
- // array = [UserGroupEntity MR_findAll];
- //
- //
- // for (UserGroupEntity *userGroupEntity in array) {
- //
- // [self.allUserGroupsDict setObject:userGroupEntity forKey:userGroupEntity.iD];
- // }
- // }
- //
- // groups(array);
- //}
- //暂时无对重复数据的过滤
- //发
- //- (MessageEntity *)createMessageWithUUID:(NSString *)uuid sessionID:(NSString *)sessionID content:(NSString *)content voiceLength:(NSNumber *)voiceLength localPath:(NSString *)localPath msgContentType:(int)conteType msgType:(int)msgType fileDownUpStatus:(int)fileDownUpStatus msgState:(int)msgState name:(NSString *)name time:(NSDate *)date unreadCount:(int)unreadCount resultBlock:(void(^)())resultBlock
- //{
- //
- //
- // NSString *messageId = nil;
- // if (!uuid) {
- // messageId = [self getMessageID];
- // }else messageId = uuid;
- //
- // //创建发送消息时间
- //
- //
- //
- //
- // NSDate *msgTime = date;
- // if (!date) msgTime = [NSDate date];
- //
- // NSString* senderID = User_Name;
- //
- // MessageEntity *msgEntity = [MessageEntity MR_createEntity];
- //
- // msgEntity.uuid = messageId;
- //
- // msgEntity.msgType = @(msgType);
- //
- // msgEntity.msgTime = msgTime;
- //
- // msgEntity.senderId = senderID;
- //
- // msgEntity.receiverId = sessionID;
- //
- // msgEntity.sessionId = sessionID;
- //
- // //默认为upload
- // msgEntity.fileDownUpStatus = @(fileDownUpStatus);
- // //默认为doing
- // msgEntity.msgState = @(msgState);
- //
- // msgEntity.msgContentType = @(conteType);
- //
- // msgEntity.msgContent = content;
- //
- // msgEntity.localPath = localPath;
- //
- // msgEntity.voiceLength = voiceLength;
- //
- // msgEntity.voicePlayed = @(1);
- //
- // //注意对富文本的处理.
- //
- // [[msgEntity managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- // }];
- //
- //// [self updateRecent];
- // [self updateRecentEntityWithMsgEntity:msgEntity unreadCount:unreadCount title:name resultBlock:^{
- //
- //
- // }];
- //
- // return msgEntity;
- //}
- //待移出数据层,此逻辑应该归入消息处理层
- //收
- //- (NSArray *)createSingleMessageWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock
- //{
- //
- // NSString *isDes = params[@"isDes"];
- // NSString *msgContent = params[@"content"];
- // if (isDes.intValue) {
- // msgContent = [[MessageHandleCenter alloc]decryptMsgWithMsgDict:params];
- // }
- // NSInteger status = [params[@"status"] integerValue];
- // NSString *msgContentType = params[@"msgType"];
- // NSString *receiver = params[@"receiver"];
- // receiver = [receiver stringByReplacingOccurrencesOfString:ContentServerID(USERDEFAULT_ContentServer) withString:@""];
- // NSString *sender = params[@"sender"];
- // sender = [sender stringByReplacingOccurrencesOfString:ContentServerID(USERDEFAULT_ContentServer) withString:@""];
- // NSString *time = params[@"time"];
- // NSDate *date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/1000];
- // NSString *uuid = params[@"uuid"];
- // NSString *length = params[@"length"];
- //#warning 2017-05-24 接口补充.
- // //
- //
- // NSString *sessionID = nil;
- // //SESSION 先判断是否同步消息,否则为sender.
- // if ([receiver isEqualToString:User_Name])
- // {
- // sessionID = sender;
- //
- // }else sessionID = receiver;
- //
- // AddrBook *addrBook = [self getAddrbookWithUerID:sessionID];
- //
- // int unreadCount = 0;
- //
- // if (status == 0 && ![sender isEqualToString:User_Name]) {
- // unreadCount = 1;
- // }
- //
- // //先判断是否是富文本
- // NSMutableArray *msgArray = [NSMutableArray array];
- //
- // if (msgContentType.intValue == MessageTypeText) {
- //
- // __block NSArray *judgeStringArray = nil;
- // NSRange range = [msgContent rangeOfString:MuiltTextPicExpression options:NSRegularExpressionSearch];
- //
- // if (range.location != NSNotFound) {
- // [Utils getPCScreenPhotoAndTextWithExpression:MuiltTextPicExpression content:msgContent resultBlock:^(NSArray *subData) {
- // judgeStringArray = subData;
- // }];
- //
- //
- // int i = 0;
- // for (NSArray *onePicTextArray in judgeStringArray) {
- //
- // i++;
- //
- // NSString *textFront = onePicTextArray[1];
- // NSString *imageMD5 = onePicTextArray[2];
- // NSString *textBack = onePicTextArray[3];
- //
- // NSString *childUUID= [NSString stringWithFormat:@"%@-%d",uuid,i];
- //
- //
- // if (textFront.length) {
- //
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:sessionID content:textFront voiceLength:0 localPath:nil msgContentType:MessageTypeText msgType:MESSAGE_TYPE_SINGLE fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:addrBook.disPlayName time:date unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // if (imageMD5.length) {
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:sessionID content:[NSString stringWithFormat:@"http://%@:%@/file/%@",[userDefaults objectForKey:USERDEFAULT_GROUP_STORAGE_HOST], [userDefaults objectForKey:USERDEFAULT_GROUP_STORAGE_PORT],imageMD5] voiceLength:0 localPath:nil msgContentType:MessageTypeImage msgType:MESSAGE_TYPE_SINGLE fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:addrBook.disPlayName time:date unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // if (textBack.length) {
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:sessionID content:textBack voiceLength:0 localPath:nil msgContentType:MessageTypeText msgType:MESSAGE_TYPE_SINGLE fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:addrBook.disPlayName time:date unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // }
- // }else{
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:uuid sessionID:sessionID content:msgContent voiceLength:@([length doubleValue]) localPath:nil msgContentType:[msgContentType intValue] msgType:MESSAGE_TYPE_SINGLE fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:addrBook.disPlayName time:date unreadCount:unreadCount resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- //
- // }
- //
- //
- //
- // }else{
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:uuid sessionID:sessionID content:msgContent voiceLength:@([length doubleValue]) localPath:nil msgContentType:[msgContentType intValue] msgType:MESSAGE_TYPE_SINGLE fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:addrBook.disPlayName time:date unreadCount:unreadCount resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- //
- // }
- //
- //
- //
- //
- //
- // return msgArray;
- //}
- //- (NSArray *)createGroupMessageWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock
- //{
- // NSString *uuid = params[@"id"];
- //
- // NSNumber *voiceLength = params[@"length"];
- //
- // NSString *content = params[@"content"];
- //
- // if(!content) content = params[@"txt"];
- //
- //// NSString *isDes = params[@"isDes"];
- //// NSString *msgContent = params[@"content"];
- //// if (isDes.intValue) {
- //// msgContent = [[MessageHandleCenter alloc]decryptMsgWithMsgDict:params];
- //// }
- // NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",TeamShareExpression];
- //
- // if ([predicate evaluateWithObject:content]) {
- // return nil;
- // }
- //
- // NSDictionary *receiveGroupDict = params[@"group"];
- //
- // NSString *sender = params[@"sender"];
- //
- // sender = [sender stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@",ContentServerID(USERDEFAULT_ContentServer)] withString:@""];
- //
- // int unreadCount = 0 ;
- //
- // if (![sender isEqualToString:User_Name]) {
- // unreadCount = 1;
- // }
- //
- // NSString *receiver = receiveGroupDict[@"id"];
- //
- // NSNumber *time = params[@"ts"];
- //
- // NSNumber *isDes = params[@"isDes"];
- //
- // NSNumber *fromClient = params[@"fromClient"];
- //
- // NSDate *msgTime = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/1000];
- //
- // MessageContentType msgContentType = [params[@"msgType"]integerValue];
- //
- // if (msgContentType == 0) {
- // msgContentType = MessageTypeText;
- // }
- //
- // UserGroupEntity *userGroup = [self.allUserGroupsDict objectForKey:receiver];
- //
- // if (!userGroup) {
- // userGroup = [UserGroupEntity findUserGroupEntityWithGroupID:receiver];
- //
- // //理论上不可能.
- // if (!userGroup) {
- // //
- // userGroup = [UserGroupEntity MR_createEntity];
- // userGroup.iD = receiver;
- // userGroup.name = receiver;
- //
- // [userGroup.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // }];
- //
- //
- // }
- //
- // [self.allUserGroupsDict setObject:userGroup forKey:receiver];
- //
- // }
- //
- // //先判断是否是富文本
- // NSMutableArray *msgArray = [NSMutableArray array];
- //
- // if (msgContentType == MessageTypeText) {
- //
- // __block NSArray *judgeStringArray = nil;
- // NSRange range = [content rangeOfString:MuiltTextPicExpression options:NSRegularExpressionSearch];
- //
- // if (range.location != NSNotFound) {
- // [Utils getPCScreenPhotoAndTextWithExpression:MuiltTextPicExpression content:content resultBlock:^(NSArray *subData) {
- // judgeStringArray = subData;
- // }];
- //
- //
- // int i = 0;
- // for (NSArray *onePicTextArray in judgeStringArray) {
- //
- // i++;
- //
- // NSString *textFront = onePicTextArray[1];
- // NSString *imageMD5 = onePicTextArray[2];
- // NSString *textBack = onePicTextArray[3];
- //
- // NSString *childUUID= [NSString stringWithFormat:@"%@-%d",uuid,i];
- //
- //
- // if (textFront.length) {
- //
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:receiver content:textFront voiceLength:0 localPath:nil msgContentType:MessageTypeText msgType:MESSAGE_TYPE_GROUP fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:userGroup.name time:msgTime unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // if (imageMD5.length) {
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:receiver content:[NSString stringWithFormat:@"http://%@:%@/file/%@",[userDefaults objectForKey:USERDEFAULT_GROUP_STORAGE_HOST], [userDefaults objectForKey:USERDEFAULT_GROUP_STORAGE_PORT],imageMD5] voiceLength:0 localPath:nil msgContentType:MessageTypeImage msgType:MESSAGE_TYPE_GROUP fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:userGroup.name time:msgTime unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // if (textBack.length) {
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:childUUID sessionID:receiver content:textFront voiceLength:0 localPath:nil msgContentType:MessageTypeText msgType:MESSAGE_TYPE_GROUP fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:userGroup.name time:msgTime unreadCount:unreadCount resultBlock:^{
- //
- //
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- // }
- //
- // }
- // }else{
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:uuid sessionID:receiver content:content voiceLength:voiceLength localPath:nil msgContentType:msgContentType msgType:MESSAGE_TYPE_GROUP fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:userGroup.name time:msgTime unreadCount:unreadCount resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- //
- // }
- //
- //
- //
- // }else{
- //
- //
- // MessageEntity *msgEntity = [self createMessageWithUUID:uuid sessionID:receiver content:content voiceLength:voiceLength localPath:nil msgContentType:msgContentType msgType:MESSAGE_TYPE_GROUP fileDownUpStatus:FileDownUpStatusDown msgState:MessageSendSuccess name:userGroup.name time:msgTime unreadCount:unreadCount resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- // [msgArray addObject:msgEntity];
- //
- // }
- //
- // return msgArray;
- //}
- //- (void)deleteMessageWithTitle:(NSString *)title UUID:(NSString *)uuid sessionID:(NSString *)sessionID resultBlock:(void(^)())resultBlock{
- //
- // //删除后获取最后一条新消息..update recentEntity
- // MessageEntity *msgEntity = [MessageEntity findMessageWithUUID:uuid];
- //
- // NSDate *lastTime = msgEntity.msgTime;
- //
- //
- // if (msgEntity) {
- // [msgEntity MR_deleteEntity];
- //
- // [msgEntity.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // NSPredicate *predicte = [NSPredicate predicateWithFormat:@"sessionId==%@ AND msgTime<=%@", sessionID,lastTime];
- //
- // //限制条数
- // NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"MessageEntity"];
- // request.fetchLimit = 1;
- // request.predicate = predicte;
- //
- // NSSortDescriptor *sortDES = [NSSortDescriptor sortDescriptorWithKey:@"msgTime" ascending:NO];
- // request.sortDescriptors = [NSArray arrayWithObject:sortDES];
- //
- // NSArray *msgEntitys = [MessageEntity MR_executeFetchRequest:request inContext:defaultContext];
- //
- // if (msgEntitys.count) {
- //
- // MessageEntity *msgEntity = msgEntitys[0];
- //
- // [self updateRecentEntityWithMsgEntity:msgEntity unreadCount:0 title:title resultBlock:^{
- //
- // }];
- //
- // }
- //
- //
- // }];
- // }
- //}
- //- (void)deleteAllMessagesWithSessionID:(NSString *)sessionID resultBlock:(void(^)())resultBlock
- //{
- // NSArray * chatMessages = [MessageEntity MR_findAllWithPredicate:[NSPredicate predicateWithFormat:@"sessionId == %@",sessionID]];
- //
- // [chatMessages enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- // //最新的消息在前,所以要反着加
- // // MessageEntity *tempMessage = offlineMessages[offlineMessages.count - 1 - idx];
- // MessageEntity *tempMessage = chatMessages[idx];
- //
- // [tempMessage MR_deleteEntity];
- //
- // }];
- //
- // dispatch_async(dispatch_get_global_queue(0, 0), ^{
- // NSManagedObjectContext *privateContext= [NSManagedObjectContext MR_contextWithParent:[NSManagedObjectContext MR_defaultContext]];
- // [privateContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // }];
- // });
- //
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:sessionID];
- //
- // if (!recentEntity) {
- //
- // recentEntity = [RecentEntity fetchEntityByRecentID:sessionID];
- //
- // }
- //
- // [recentEntity MR_deleteEntity];
- //
- // [[recentEntity managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- //
- // }];
- //
- //}
- //- (void)getLatestMessageInGroupWithGroupID:(NSString *)groupID resultBlock:(void(^)(MessageEntity *msgEntity))resultBlock
- //{
- // NSDate *lastTime = [NSDate date];
- //
- // NSPredicate *predicte = [NSPredicate predicateWithFormat:@"sessionId==%@ AND msgTime<=%@", groupID,lastTime];
- //
- // //限制条数
- // NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"MessageEntity"];
- // request.fetchLimit = 1;
- // request.predicate = predicte;
- //
- // NSSortDescriptor *sortDES = [NSSortDescriptor sortDescriptorWithKey:@"msgTime" ascending:NO];
- // request.sortDescriptors = [NSArray arrayWithObject:sortDES];
- //
- // NSArray *msgEntitys = [MessageEntity MR_executeFetchRequest:request inContext:defaultContext];
- //
- // if (msgEntitys.count) {
- //
- // MessageEntity *msgEntity = msgEntitys[0];
- //
- // if (resultBlock) {
- //
- // resultBlock(msgEntity);
- // }
- //
- // }
- //
- //}
- //- (NoticeModels *)createNoticeModelWithJSONParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock{
- //
- // NoticeModels *noticeModel = [NoticeModels MR_findFirstWithPredicate:[NSPredicate predicateWithFormat:@"uuid = %@",params[@"uuid"]]];
- //
- // if (noticeModel) {
- // return nil;
- // }else{
- //
- // noticeModel = [NoticeModels MR_createEntity];
- //
- // noticeModel.sender = params[@"sender"];
- // noticeModel.receiver = params[@"receiver"];
- // noticeModel.title = params[@"title"];
- // noticeModel.content = params[@"content"];
- // noticeModel.url = params[@"url"];
- //
- // //字典新增几个字段.
- // NSMutableArray *tempArray = [NSMutableArray array];
- //
- // int i = 0;
- // for (NSDictionary *attachmentDict in params [@"attachments"]) {
- //
- //
- // NSString *uuid = [NSString stringWithFormat:@"%@-%d",params[@"uuid"],i];
- //
- // NSMutableDictionary *newAttachmentDict = [NSMutableDictionary dictionaryWithDictionary:attachmentDict];
- // [newAttachmentDict setObject:uuid forKey:@"uuid"];
- // [newAttachmentDict setObject:@0 forKey:@"isDownloaded"];
- // [newAttachmentDict setObject:@"null" forKey:@"localPath"];
- //
- // [tempArray addObject:newAttachmentDict];
- //
- // i++;
- //
- //
- // }
- //
- // noticeModel.attachments = tempArray;
- // //来源
- // noticeModel.appName = params[@"appName"];
- // noticeModel.uuid = params[@"uuid"];
- // noticeModel.unreadIndifier = @1;
- //
- // NSString *time = [NSString stringWithFormat:@"%@",params[@"timestamp"]];
- //
- // NSDate *date = [NSDate dateWithTimeIntervalSince1970:[time doubleValue]/1000];
- // noticeModel.timeStamp = date;
- //
- // [noticeModel.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- //
- // }];
- //
- //
- // return noticeModel;
- // }
- //
- //}
- //- (RecentEntity *)updateRecentEntityWithSessionID:(NSString *)sessionID type:(int)type title:(NSString *)title uuid:(NSString *)uuid lastTime:(NSDate *)lastTime unreadCount:(NSInteger)unreadCount lastMsg:(NSString *)lastMsg resultBlock:(void(^)())resultBlock
- //{
- //
- // return nil;
- //}
- //- (RecentEntity *)updateRecentEntityWithMsgEntity:(MessageEntity *)msgEntity unreadCount:(int)unreadCount title:(NSString *)title resultBlock:(void(^)())resultBlock
- //{
- //
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:msgEntity.sessionId];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity fetchEntityByRecentID:msgEntity.sessionId];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity MR_createEntity];
- // }
- //
- //
- //
- // recentEntity.recentId = msgEntity.sessionId;
- //
- // recentEntity.type = msgEntity.msgType;
- //
- // //待调整...
- // recentEntity.title = title;
- //
- // [self.allUserRecentsDict setObject:recentEntity forKey:msgEntity.sessionId];
- // }
- //
- // if([msgEntity.msgTime compare:recentEntity.lastTime] == NSOrderedDescending || !recentEntity.lastTime)
- // {
- // //未读消息数有问题.
- // recentEntity.uuid = msgEntity.uuid;
- //
- // recentEntity.lastTime = msgEntity.msgTime;
- //
- // recentEntity.unreadCount = @([recentEntity.unreadCount intValue] + unreadCount);
- //
- // switch (msgEntity.msgContentType.integerValue) {
- //
- // case MessageTypeText:
- //
- // recentEntity.lastMsg = msgEntity.msgContent;
- // break;
- // case MessageTypeNotice:
- //
- // recentEntity.lastMsg = msgEntity.msgContent;
- // break;
- // case MessageTypeFile:
- //
- // recentEntity.lastMsg = @"[文件]";
- // break;
- // case MessageTypeVoice:
- //
- // recentEntity.lastMsg = @"[语音]";
- // break;
- // case MessageTypeImage:
- //
- //
- // recentEntity.lastMsg = @"[图片]";
- // break;break;
- // case MessageTypeLocation:
- //
- // recentEntity.lastMsg = @"[位置]";
- // break;break;
- // default:
- // break;
- // }
- //
- // [[recentEntity managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- //
- // }
- //
- // return recentEntity;
- //}
- //- (RecentEntity *)updateRecentEntityWithSessionID:(NSString *)sessionID type:(MessageType)type title:(NSString *)title lastTime:(NSDate *)date lastMsg:(NSString *)lastMsg unreadCount:(int)unreadCount resultBlock:(void(^)())resultBlock
- //{
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:sessionID];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity fetchEntityByRecentID:sessionID];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity MR_createEntity];
- // }
- //
- //
- //
- // recentEntity.recentId = sessionID;
- //
- // recentEntity.type = @(type);
- //
- // recentEntity.title = title;
- //
- // [self.allUserRecentsDict setObject:recentEntity forKey:sessionID];
- // }
- //
- // if([date compare:recentEntity.lastTime] == NSOrderedDescending || !recentEntity.lastTime)
- // {
- //
- //
- // recentEntity.lastTime = [NSDate date];
- // recentEntity.lastMsg = lastMsg;
- // recentEntity.unreadCount = @(recentEntity.unreadCount.intValue + unreadCount);
- // [recentEntity.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- // }];
- //
- // }
- //
- // return recentEntity;
- //}
- //手动创造
- //- (UserGroupEntity *)createGroupEntityWithGroupID:(NSString *)groupID groupName:(NSString *)groupName creator:(NSString *)creator managers:(NSArray *)managers groupMembers:(NSArray *)groupMembers groupHeaderImage:(UIImage *)groupHeaderImage createTs:(NSDate *)ts ActiveAs:(NSDate *)as JoinJs:(NSDate *)js ignores:(NSArray *)ignors tags:(NSArray *)tags notice:(NSString *)notice intro:(NSString *)intro invite:(NSNumber *)invite type:(NSNumber *)type ver:(NSNumber *)ver auth:(NSNumber *)auth msgReceiveLevel:(NSNumber *)msgReceiveLevel unreadMsgCount:(NSNumber *)unradMsgCount unreadMsgIdentifierDict:(NSDictionary *)unreadMsgIdentifierDict resultBlock:(void(^)())resultBlock{
- //
- // UserGroupEntity *userGroupEntity = [UserGroupEntity findUserGroupEntityWithGroupID:groupID];
- //
- // if (userGroupEntity) {
- // return nil;
- // }else{
- //
- // userGroupEntity = [UserGroupEntity MR_createEntity];
- //
- // userGroupEntity.iD = groupID;
- //
- // NSComparator cmptr = ^(NSDictionary *userA, NSDictionary *userB){
- // if ([userA[@"ts"]integerValue] > [userB[@"ts"]integerValue]) {
- // return (NSComparisonResult)NSOrderedDescending;
- // }
- //
- // if ([userA[@"ts"]integerValue] < [userB[@"ts"]integerValue]) {
- // return (NSComparisonResult)NSOrderedAscending;
- // }
- // return (NSComparisonResult)NSOrderedSame;
- //
- // };
- // NSArray *array = [groupMembers sortedArrayUsingComparator:cmptr];
- //
- // userGroupEntity.members = array;
- //
- // userGroupEntity.managers = managers;
- //
- // userGroupEntity.tags = tags;
- //
- // userGroupEntity.ignores = ignors;
- //
- // userGroupEntity.as = as;
- //
- // userGroupEntity.ts = ts;
- //
- // //自己创建时...
- // userGroupEntity.js = [NSDate date];
- //
- // userGroupEntity.invite = @(invite.boolValue);
- //
- // userGroupEntity.creator = creator;
- //
- // userGroupEntity.intro = intro;
- //
- // userGroupEntity.name = groupName;
- //
- // userGroupEntity.notice = notice;
- //
- // userGroupEntity.ver = ver;
- //
- // userGroupEntity.type = type;
- //
- // userGroupEntity.auth = auth;
- //
- // userGroupEntity.groupHeaderImage = groupHeaderImage;
- //
- // [userGroupEntity.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- // }];
- //
- // [self.allUserGroupsDict setObject:userGroupEntity forKey:groupID];
- //
- // }
- //
- // //update recent..
- // [self updateRecentEntityWithSessionID:userGroupEntity.iD type:MESSAGE_TYPE_GROUP title:userGroupEntity.name lastTime:[NSDate date] lastMsg:@"群创建成功" unreadCount:1 resultBlock:^{
- //
- //
- // }];
- //
- // return userGroupEntity;
- //
- //
- //}
- //- (UserGroupEntity *)createGroupEntityWithGroupParams:(NSDictionary *)dict resultBlock:(void(^)())resultBlock
- //{
- //
- // NSDictionary *memebersDict = dict[@"members"];
- // //头像
- // GroupHeaderImageView *headerImageView = [[GroupHeaderImageView alloc]initWithHeaderWH:UserGroupShowCellHeaderViewWH];
- // headerImageView.bounds = CGRectMake(0, 0, UserGroupShowCellHeaderViewWH, UserGroupShowCellHeaderViewWH);
- // headerImageView.groupMembersArray = memebersDict.allValues;
- // UIImage *groupHeaderImage = [Utils imageWithView:headerImageView];
- //
- //
- // UserGroupEntity *userGroupEntity = [self createGroupEntityWithGroupID:dict[@"id"] groupName: dict[@"name"] creator:dict[@"creator"] managers: dict[@"managers"]groupMembers:dict[@"members"] groupHeaderImage:groupHeaderImage createTs:[NSDate dateWithTimeIntervalSince1970:[dict[@"ts"] doubleValue]/1000] ActiveAs:[NSDate dateWithTimeIntervalSince1970:[dict[@"as"] doubleValue]/1000] JoinJs:[NSDate date] ignores: dict[@"ignores"] tags: dict[@"tags"] notice: dict[@"notice"] intro:dict[@"intro"] invite:dict[@"invite"] type:dict[@"type"] ver: dict[@"ver"] auth: dict[@"auth"] msgReceiveLevel:nil unreadMsgCount:nil unreadMsgIdentifierDict:nil resultBlock:^{
- //
- // }];
- //
- // return userGroupEntity;
- //
- //}
- //待新增启动更新
- //- (UserGroupEntity *)updateGroupEntityWithParams:(NSDictionary *)params resultBlock:(void(^)())resultBlock
- //{
- // NSString *ID = params[@"id"];
- // UserGroupEntity *userGroupEntity = [self.allUserGroupsDict objectForKey:ID];
- //
- // if (!userGroupEntity) {
- // userGroupEntity = [UserGroupEntity findUserGroupEntityWithGroupID:ID];
- //
- // if (!userGroupEntity) {
- //
- // NSDictionary *memebersDict = params[@"members"];
- // //头像
- // GroupHeaderImageView *headerImageView = [[GroupHeaderImageView alloc]initWithHeaderWH:UserGroupShowCellHeaderViewWH];
- // headerImageView.bounds = CGRectMake(0, 0, UserGroupShowCellHeaderViewWH, UserGroupShowCellHeaderViewWH);
- // headerImageView.groupMembersArray = memebersDict.allValues;
- // UIImage *groupHeaderImage = [Utils imageWithView:headerImageView];
- //
- //#warning 2017-05-27 js 不清不楚.
- // userGroupEntity = [self createGroupEntityWithGroupID:ID groupName:params[@"name"] creator:params[@"creator"] managers:params[@"managers"] groupMembers:params[@"members"] groupHeaderImage:groupHeaderImage createTs:[NSDate dateWithTimeIntervalSince1970:[params[@"ts"] doubleValue]/1000] ActiveAs:[NSDate dateWithTimeIntervalSince1970:[params[@"as"] doubleValue]/1000] JoinJs:nil ignores:params[@"ignores"] tags:params[@"tags"] notice:params[@"notice"] intro:params[@"intro"] invite:[NSNumber numberWithBool:[params[@"invite"]boolValue]] type:params[@"type"] ver:params[@"ver"] auth:params[@"auth"] msgReceiveLevel:nil unreadMsgCount:nil unreadMsgIdentifierDict:nil resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- //
- // }
- //
- // [self.allUserGroupsDict setObject:userGroupEntity forKey:ID];
- // }
- //
- // if (userGroupEntity && [userGroupEntity.ver longLongValue] < [params[@"ver"]longLongValue]) {
- //
- // NSDictionary *memebersDict = params[@"members"];
- // //头像
- // GroupHeaderImageView *headerImageView = [[GroupHeaderImageView alloc]initWithHeaderWH:UserGroupShowCellHeaderViewWH];
- // headerImageView.bounds = CGRectMake(0, 0, UserGroupShowCellHeaderViewWH, UserGroupShowCellHeaderViewWH);
- // headerImageView.groupMembersArray = memebersDict.allValues;
- // UIImage *groupHeaderImage = [Utils imageWithView:headerImageView];
- //
- // [self updateGroupEntityWithGroupID:ID groupName:params[@"name"] creator:params[@"creator"] managers:params[@"managers"] groupMembers:params[@"members"] groupHeaderImage:groupHeaderImage createTs:[NSDate dateWithTimeIntervalSince1970:[params[@"ts"] doubleValue]/1000] ActiveAs:[NSDate dateWithTimeIntervalSince1970:[params[@"as"] doubleValue]/1000] JoinJs:[NSDate date] ignores:params[@"ignores"] tags:params[@"tags"] notice:params[@"notice"] intro:params[@"intro"] invite:[NSNumber numberWithBool:[params[@"invite"]boolValue]] type:params[@"type"] ver:params[@"ver"] auth:params[@"auth"] resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- // }
- //
- //
- // return userGroupEntity;
- //
- //}
- //群解散
- //- (void)deleteGroupWithGroupID:(NSString *)groupID resultBlock:(void(^)())resultBlock
- //{
- // UserGroupEntity *userGroupEntity = [self.allUserGroupsDict objectForKey:groupID];
- //
- // if (!userGroupEntity) {
- // userGroupEntity = [UserGroupEntity findUserGroupEntityWithGroupID:groupID];
- // }
- //
- // NSString *title = userGroupEntity.name;
- //
- // [userGroupEntity MR_deleteEntity];
- //
- // [userGroupEntity.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:groupID];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity fetchEntityByRecentID:groupID];
- //
- // if (!recentEntity) {
- //
- //#warning ...
- // [self updateRecentEntityWithSessionID:groupID type:MESSAGE_TYPE_GROUP title:title lastTime:[NSDate date] lastMsg:@"该群组已被解散" unreadCount:1 resultBlock:^{
- //
- // if (resultBlock) {
- // resultBlock();
- // }
- //
- // }];
- //
- // }
- // }
- //
- //
- // }];
- //}
- //- (void)kickOutFromGroupWithGroupID:(NSString *)groupID resultBlock:(void(^)())resultBlock
- //{
- // UserGroupEntity *userGroupEntity = [self.allUserGroupsDict objectForKey:groupID];
- //
- // if (!userGroupEntity) {
- // userGroupEntity = [UserGroupEntity findUserGroupEntityWithGroupID:groupID];
- // }
- //
- //
- // [userGroupEntity MR_deleteEntity];
- //
- // [userGroupEntity.managedObjectContext MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:groupID];
- //
- // if (!recentEntity) {
- // recentEntity = [RecentEntity fetchEntityByRecentID:groupID];
- //
- // [recentEntity MR_deleteEntity];
- //
- // [[recentEntity managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // }];
- //
- // }
- //
- //
- // }];
- //}
- //群未读消息标记及群的提醒等级单独接口. //msgReceiveLevel:(NSNumber *)msgReceiveLevel unreadMsgCount:(NSNumber *)unradMsgCount unreadMsgIdentifierDict:(NSDictionary *)unreadMsgIdentifierDict
- //- (UserGroupEntity *)updateGroupEntityWithGroupID:(NSString *)groupID groupName:(NSString *)groupName creator:(NSString *)creator managers:(NSArray *)managers groupMembers:(NSArray *)groupMembers groupHeaderImage:(UIImage *)groupHeaderImage createTs:(NSDate *)ts ActiveAs:(NSDate *)as JoinJs:(NSDate *)js ignores:(NSArray *)ignors tags:(NSArray *)tags notice:(NSString *)notice intro:(NSString *)intro invite:(NSNumber *)invite type:(NSNumber *)type ver:(NSNumber *)ver auth:(NSNumber *)auth resultBlock:(void(^)())resultBlock{
- //
- // //理论上无需判断是否group存在..
- //
- // UserGroupEntity *userGroup = [self.allUserGroupsDict objectForKey:groupID];
- //
- // if (groupName) {
- // userGroup.name = groupName;
- // }
- //
- // if (creator) {
- // userGroup.creator = creator;
- // }
- //
- // if (managers) {
- // userGroup.managers = managers;
- // }
- //
- // if (groupMembers) {
- //
- // NSComparator cmptr = ^(NSDictionary *userA, NSDictionary *userB){
- // if ([userA[@"ts"]integerValue] > [userB[@"ts"]integerValue]) {
- // return (NSComparisonResult)NSOrderedDescending;
- // }
- //
- // if ([userA[@"ts"]integerValue] < [userB[@"ts"]integerValue]) {
- // return (NSComparisonResult)NSOrderedAscending;
- // }
- // return (NSComparisonResult)NSOrderedSame;
- //
- // };
- // NSArray *array = [groupMembers sortedArrayUsingComparator:cmptr];
- //
- // userGroup.members = array;
- // }
- //
- // if (groupHeaderImage) {
- // userGroup.groupHeaderImage = groupHeaderImage;
- // }
- //
- // if (ts) {
- // userGroup.ts = ts;
- // }
- //
- // if (as) {
- // userGroup.as = as;
- // }
- //
- // if (js) {
- // userGroup.js = js;
- // }
- //
- // if (ignors) {
- // userGroup.ignores = ignors;
- // }
- //
- // if (tags) {
- // userGroup.tags = tags;
- // }
- //
- // if (notice) {
- // userGroup.notice = notice;
- // }
- //
- // if (intro) {
- // userGroup.intro = intro;
- // }
- //
- // userGroup.invite = invite;
- //
- // userGroup.type = type;
- //
- // userGroup.ver = ver;
- //
- // userGroup.auth = auth;
- //
- // [[userGroup managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- // if (resultBlock) {
- // resultBlock();
- // }
- // }];
- //
- // //更新recent的title.
- // RecentEntity *recentEntity = [self.allUserRecentsDict objectForKey:groupID];
- //
- // if (!recentEntity) {
- //
- // recentEntity = [RecentEntity fetchEntityByRecentID:groupID];
- //
- // }
- //
- //
- // if (recentEntity) {
- // recentEntity.title = groupName;
- //
- // [[recentEntity managedObjectContext]MR_saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
- //
- // }];
- // }
- //
- //
- // return userGroup;
- //}
- //返回用户对象<用户信息已经得到>
- //-(AddrBook*) p_fetchAddrBookForReceivedMessage:(NSString*)senderId
- //{
- // /*
- // componentsSeparatedByString: 将字符串切割成数组, 参数是作为分割辨认用的
- // */
- // //通过 '-' 为切割点,将字符串切割成数组
- // NSArray *tempArray = [senderId componentsSeparatedByString:@"-"];
- // //获取字符
- // if (tempArray.count != 2) {
- // return nil;
- // }
- // NSString *loginName = tempArray[1];
- // NSString *serverID = tempArray[0];
- // /*
- // fetchEntityByLoginName: serverID: 是通过这 loginName 和 serverID 作为唯一标识符 , 来查询对象
- // */
- // //获取对象 <相当于创建了一个对象 对象里面有信息>
- // __block AddrBook *addrbook = [AddrBook fetchEntityByLoginName:loginName serverID:serverID];
- // if (!addrbook) {
- //
- //
- //
- // NSDictionary *params = @{
- // @"serverID":serverID,
- // @"userName":loginName
- // };
- // [HttpManager postRequestToUrlSynchornize:FULL_URL(@"users/getUserDetail") params:params complete:^(BOOL successed, NSDictionary *result) {
- // //成功并返回一个正确的 bool 值
- // if (successed && [result[@"success"]boolValue]) {
- // //从 result 取得字典数据
- // NSDictionary *userDic = result[@"data"];
- // //从字典数据中获取 id 数据
- // NSNumber *idx = userDic[@"id"];
- //
- //
- // NSLog(@"userDic: - - - > %@ < - - - ",userDic);
- //
- //
- // if (idx!=0) {
- // //获取用户对象
- // addrbook = [AddrBook insertEntityByID:idx];
- // //获取对象的所有属性数据
- // [addrbook updatePropertyByDictionary:userDic];
- // }
- // //保存
- //
- // dispatch_async(dispatch_get_global_queue(0, 0), ^{
- // NSManagedObjectContext *privateContext= [NSManagedObjectContext MR_contextWithParent:[NSManagedObjectContext MR_defaultContext]]; [privateContext MR_saveToPersistentStoreAndWait];
- // });
- // }
- // }];
- // }
- // return addrbook;
- //}
- //- (AddrBook *)getAddrbookWithUerID:(NSString *)userID
- //{
- //
- // AddrBook *addrBook = [self.allUserDict objectForKey:userID];
- //
- // if (!addrBook) {
- // addrBook = [self p_fetchAddrBookForReceivedMessage:userID];
- //
- // [self.allUserDict setObject:addrBook forKey:userID];
- // }
- //
- //
- // return addrBook;
- //
- //}
- //- (AddrBook *)createUserDetailsWithJSONParams:(NSDictionary *)prams resultBlock:(void(^)())resultBlock
- //{
- // /*
- // Dictionary2Object(dictionary, @"id", self.addrBookID);
- // self.postion = [NSString stringWithFormat:@"%@",dictionary[@"position"]];
- // // Dictionary2Object(dictionary, @"position", self.postion);
- // Dictionary2Object(dictionary, @"groupId", self.groupID);
- // Dictionary2Object(dictionary, @"defaultLoginName", self.defaultLoginName);
- // Dictionary2Object(dictionary, @"telephone", self.telephone);
- // Dictionary2Object(dictionary, @"cellphone", self.cellTelephone);
- // Dictionary2Object(dictionary, @"celltelephone", self.cellTelephone);
- // Dictionary2Object(dictionary, @"serverID", self.serverID);
- // Dictionary2Object(dictionary, @"email", self.email);
- // Dictionary2Object(dictionary, @"remark", self.remark);
- // Dictionary2Object(dictionary, @"postion", self.postion);
- // Dictionary2Object(dictionary, @"branchId", self.branchId);
- // Dictionary2Object(dictionary, @"branchID", self.branchId);
- // Dictionary2Object(dictionary, @"mobile", self.cellTelephone);
- //
- // Dictionary2Object(dictionary, @"shortMobile", self.shortMobile);
- // Dictionary2Object(dictionary, @"tel", self.telephone);
- // // Dictionary2Object(dictionary, @"department", self.department);
- // // Dictionary2Object(dictionary, @"company", self.company);
- // Dictionary2Object(dictionary, @"secret", self.secret);
- // // self.secret = Numberi(2);
- //
- // // Dictionary2TimeObject(dictionary, @"createTime", self.createTime);
- // Dictionary2Object(dictionary, @"deleted", self.deleted);
- // Dictionary2Object(dictionary, @"branch", self.department);
- // Dictionary2Object(dictionary, @"duty", self.duty);
- // Dictionary2Object(dictionary, @"gender", self.gender);
- // Dictionary2Object(dictionary, @"loginName", self.name);
- // // Dictionary2Object(dictionary, @"version", self.version);
- // if (self.loginState) {
- // Dictionary2Object(dictionary, @"loginState", self.loginState);
- // }
- // if (self.appState){
- // Dictionary2Object(dictionary, @"appState", self.appState);
- // }
- //
- // Dictionary2Object(dictionary, @"loginName", self.loginName);
- // Dictionary2Object(dictionary, @"displayName", self.disPlayName);
- // Dictionary2Object(dictionary, @"headImageUrl", self.avatar);
- // Dictionary2Object(dictionary, @"company", self.company);
- // Dictionary2Object(dictionary, @"watchword", self.signature);
- //
- // // Dictionary2Object(dictionary, @"avatarColor", self.avatarColor);
- // //同步loginName 和 defaultLoginName
- // if (self.loginName.length!=0) {
- // self.defaultLoginName = self.loginName;
- // }else{
- // self.loginName = self.defaultLoginName;
- // }
- //
- // self.state = @(0);
- //
- // */
- // return nil;
- //}
- //- (AddrBook *)updateUserDetailsWithJSONParams:(NSDictionary *)prams resultBlock:(void(^)())resultBlock
- //{
- //// [AddrBook updateUsersDetail:prams];
- // return nil;
- //}
- @end
|