| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322 |
- //
- // HttpRequest.m
- // zhuxun
- //
- // Created by 张建伟 on 15/4/7.
- // Copyright (c) 2015年 张建伟. All rights reserved.
- //
- #import "HttpRequest.h"
- //#import "LoginAPI.h"
- //#import "AuthAPI.h"
- #import "NSMutableDictionary+MuiltKeyValue.h"
- #define CloudStorageURL @"http://192.168.16.181:9123"//开发测试_云盘_API地址
- //#define CloudStorageURL @"http://netdisk.cloud.wswin.cn:9123"//生产环境_云盘_API地址
- #define CloudStorageDownUpUrl @"http://192.168.16.181"//开发测试_云盘_上传下载地址
- //#define CloudStorageDownUpUrl @"http://netdisk.cloud.wswin.cn:9120"//生产环境_云盘_上传下载地址
- @implementation HttpRequest
- + (instancetype)sharedManager {
- static HttpRequest *shared_manager = nil;
- static dispatch_once_t pred;
- dispatch_once(&pred, ^{
- shared_manager = [[HttpRequest alloc] init];
- });
- return shared_manager;
- }
- #pragma mark Login
- - (void)request_Login_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block{
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:@"" withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- //获取数据
- id resultData = [data valueForKeyPath:@"data"];
- // if (resultData) {
- // User *curLoginUser = [NSObject objectOfClass:@"User" fromJSON:resultData];
- // if (curLoginUser) {
- // [Login doLogin:resultData];
- // }
- // block(curLoginUser, nil);
- // }else{
- // block(nil, error);
- // }
-
- }];
- }
- //--ok
- #warning 安全改造后以下代码无用##############################################
- -(void)postLoginParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
-
- NSString *path = @"/v1/user/login";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStoragePostLoginWithParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/login";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
- if (![resultData isKindOfClass:[NSNull class]]) {
- NSString *auth = resultData[@"authorization"];
- if (auth) {
- [userDefaults setObject:auth forKey:@"authorization"];
- }
- }
-
-
- NSString * key = [userDefaults objectForKey:@"authorization"];
-
- if (!key) {
- [userDefaults setObject:@"eHhqOkEwQTQ3NUNGNDU0Q0Y5QTA2OTc5MDM0MDk4MTY3QjlF" forKey:@"authorization"];
- }
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetFilesWithPid:(NSString *)pid searchKey:(NSString *)key ext:(NSString *)ext complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if (pid) {
- [dict setObject:pid forKey:@"pid"];
- }
-
- if (key) {
- [dict setObject:key forKey:@"key"];
- }
-
- if (ext) {
- [dict setObject:ext forKey:@"ext"];
- }
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Get andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetRecycledFilesWithComplete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item/recycle";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageFileDeleteWithItemIDs:(NSArray *)fileIDs deleteLevel:(NSInteger)deleteLevel complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item/delete";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if (fileIDs) {
- [dict setObject:fileIDs forKey:@"item_ids"];
- }
-
- if (deleteLevel) {
- [dict setObject:@(deleteLevel) forKey:@"is_remove"];
- }
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetAllFolderWithPid:(NSString *)pid excludeIds:(NSArray *)excludeIds complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = [NSString stringWithFormat:@"/v2/api/item/%@/folder",pid];
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if (excludeIds) {
- [dict setObject:excludeIds forKey:@"item_ids"];
- }
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetAllChildsWithPids:(NSArray *)pids complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item/childs";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if (pids) {
- [dict setObject:pids forKey:@"ids"];
- }
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageFileReNameWithNewName:(NSString *)name fileID:(NSString *)itemID complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item/rename";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
-
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if (name) {
- [dict setObject:name forKey:@"name"];
- }
-
- if (itemID) {
- [dict setObject:itemID forKey:@"_id"];
- }
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageCreateNewFileFolderWithFolderName:(NSString *)folderName pid:(NSString *)pid delflag:(NSString *)delflag complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- [dict setObject:@1 forKey:@"isdir"];
-
- if (folderName) {
- [dict setObject:folderName forKey:@"name"];
- }
-
- if (pid) {
- [dict setObject:pid forKey:@"pid"];
- }
-
- if (delflag) {
- [dict setObject:delflag forKey:@"delflag"];
- }
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageCheckFileNameIsExitWithPid:(NSString *)pid fileName:(NSString *)fileName isdir:(BOOL)isdir ext:(NSString *)ext complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item/check_rename";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- [dict setObject:pid forKey:@"pid"];
- [dict setObject:fileName forKey:@"name"];
- [dict setObject:@(isdir) forKey:@"isdir"];
-
-
- if (ext) {
- [dict setObject:ext forKey:@"ext"];
- }
-
-
-
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageCreateNewFileWithFileName:(NSString *)fileName md5:(NSString *)md5 pid:(NSString *)pid delflag:(NSString *)delflag ext:(NSString *)ext size:(NSNumber*)size complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = @"/v2/api/item";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- [dict setObject:@0 forKey:@"isdir"];
-
- if (fileName) {
- [dict setObject:fileName forKey:@"name"];
- }
-
- if (pid) {
- [dict setObject:pid forKey:@"pid"];
- }else{
-
- [dict setObject:@"0" forKey:@"pid"];
- }
-
- if (delflag) {
- [dict setObject:delflag forKey:@"delflag"];
- }
-
-
- //
- if (md5) {
- [dict setObject:md5 forKey:@"md5"];
- }
-
- if (ext) {
- [dict setObject:ext forKey:@"ext"];
- }
-
- if (size) {
- [dict setObject:size forKey:@"size"];
- }
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- -(void)cloudStorageMoveFilesToOtherPid:(NSString *)pid needMoveFiles:(NSArray *)csfiles complete:(void (^)(BOOL, id, NSError *))complete
- {
- NSString *path = [NSString stringWithFormat:@"/v2/api/item/move_file/to/%@",pid];
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:csfiles forKey:@"item_ids"];
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageCopyFilesToOtherPid:(NSString *)pid needCopyFiles:(NSArray *)csfiles complete:(void (^)(BOOL, id, NSError *))complete{
- NSString *path = [NSString stringWithFormat:@"/v2/api/item/copy_file/to/%@",pid];
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- [dict setObject:csfiles forKey:@"item_ids"];
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"data"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetFileDownloadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = [NSString stringWithFormat:@"/api/download/%@",md5];
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageDownUpUrl,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- // [dict setObject:md5 forKey:@"md5"];
-
- [[HttpClient sharedJsonClient] cloudStorageDownUpJsonDataWithPath:fullPath withParams:dict withMethodType:Get andBlock:^(id data, NSError *error) {
-
-
- if (data) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
-
- }];
-
- }
- - (void)cloudStorageGetFileUploadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
- NSString *path = [NSString stringWithFormat:@"/api/upload/%@/%@",@"tcp",md5];
- // NSString *path = @"/api/upload";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageDownUpUrl,path];
- // NSMutableDictionary *dict = [NSMutableDictionary dictionary];
-
- // [dict setObject:md5 forKey:@"md5"];
- // [dict setObject:@"tcp" forKey:@"type"];
-
- [[HttpClient sharedJsonClient] cloudStorageDownUpJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
-
- if (data) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageCreateShareFiles:(NSArray *)filesdic WithReceivers:(NSArray*)receivers complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
-
- NSString *path = @"/v2/api/share";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- NSMutableString *mstr = [NSMutableString string];
- NSMutableArray *item_ids = [NSMutableArray array];
- [dict setObject:receivers forKey:@"users"];//移动端没有部门 直接用户多选
- for (NSDictionary *sdic in filesdic) {
- NSString *name = [sdic objectForKey:@"name"];
- NSString *item_id = [sdic objectForKey:@"id"];
- [mstr appendString:name];
- [item_ids addObject:item_id];
- }
- NSDictionary *share_file =@{@"name":mstr,
- @"item_ids":item_ids};
-
- [dict setObject:share_file forKey:@"share_file"];
-
-
-
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (data) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- - (void)cloudStorageGetShareFiles:(NSString *)shareID complete:(void (^)(BOOL success, id data, NSError *error)) complete
- {
-
- NSString *path = @"/v2/api/share/package/";
- NSString *fullPath = [NSString stringWithFormat:@"%@%@%@",CloudStorageURL,path,shareID];
- [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
-
- if (data) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- #pragma mark --- 云盘相关结束
- //
- ////获取群组通信和存储信息 --ok
- //-(void)getGroupParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
- //{
- //
- // NSString *path = @"/v1/servers";
- // NSString *aPath = [NSString stringWithFormat:@"http://%@:%@%@",[userDefaults objectForKey:USERDEFAULT_GROUP_HOST],[userDefaults objectForKey:USERDEFAULT_GROUP_PORT],path];
- //#warning 2016-06-28 中心服务器地址有问题??
- // [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
- //
- //
- // /*
- // {
- // "socket": {
- // "host": "120.26.126.129",
- // "port": 6714,
- // "id": "120.26.126.129:6714",
- // "online": 4,
- // "type": "mix",
- // "ver": "3.2.0"
- // },
- // "storage": {
- // "host": "120.26.126.129",
- // "port": 6713
- // }
- // }
- // */
- //
- // complete(data?1:0,data,error);
- //
- // }];
- //}
- //
- //--ok
- -(void)postDeviceInfo:(NSDictionary *)params complete:(void (^)(BOOL, id, NSError *))complete{
- NSString *path = @"/v1/device/perfect";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- id resultData = [data valueForKey:@"message"];
-
-
- if (resultData) {
- complete(YES,data,nil);
- }else{
-
- complete(NO,nil,error);
- }
-
- }];
- }
- //--ok
- -(void)request_resetUnreadCount_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/devices/resetUnreadCount";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- // User *curLoginUser = [NSObject objectOfClass:@"User" fromJSON:resultData];
- // if (curLoginUser) {
- // [Login doLogin:resultData];
- // }
- // block(curLoginUser, nil);
- }else{
- // block(nil, error);
- }
- }];
- }
- //--ok
- -(void)search_users_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/branchs/searchUsers";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- //@"branchs/searchUsers"
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- //获取数据
- id resultData = [data valueForKeyPath:@"data"];
-
- //如果数据存在
- if (resultData) {
- //获取对象数组
- // NSArray *items = [resultData valueForKeyPath:@"items"];
- //将数组传递出去
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //-ok
- #warning mark - - users/getUserDetail
- -(void)request_userDetail_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/users/getUserDetail";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
-
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //请求用户状态--废弃
- -(void)request_userState_WithParams:(id)params andBlock:(void (^)(id, NSError *))block{
-
-
- // NSString *StrUrl = @"http://120.26.126.129:30001/zhuxunserver/users/getUserStates"; /zhuxunserver/
- NSString *path = @"/zhuxunserver/users/getUserStates";
- NSString *aPath =[NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] postRequestToUrl:aPath netWorkMethod:Post aPath:aPath WithParams:params complete:^(BOOL successed, NSDictionary *result) {
-
- id resultData = [result valueForKeyPath:@"data"];
-
- // NSLog(@"resultData: %@",resultData);
-
- // if (result) {
- block(resultData,nil);
- // }
- }];
- }
- //请求多用户状态
- -(void)request_UserDetailListWith:(id)params andBlock:(void(^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/users/detailList";
- NSString *aPath =[NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
-
- //提示
- return ;
- }
-
- id result = data[@"data"];
-
- if (!result) {
- return;
- }
-
- block(result,nil);
-
-
- }];
- }
- //--废弃
- -(void)request_Branches_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- //客户端的数据请求 类型为 post params: -1
-
- NSString *path = @"/zhuxunserver/branchs/getBranchsByParentID";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //通过传入的参数 'params' ,向服务器获取所有的分支机构--ok
- -(void)request_allChildOfBranch_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/branchs/getAllChildrenByParentID";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //--ok
- -(void)upload_headImage_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/zhuxunserver/users/uploadHeadImage";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
-
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //同步通讯录 使用数据请求--ok
- -(void)request_personalAddrbook_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/zhuxunserver/addressBooks/sync";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- //取数据 data
- id resultData = [data valueForKeyPath:@"data"];
- //如果有数据,就block回调数据
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //--ok
- -(void)request_sendSMS_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/zhuxunserver/sms/sendCode";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- //原来的是 sms/sendCode
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
-
- NSLog(@"resultData: %@",resultData);
-
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
- }
- //--ok
- -(void)request_authSMS_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/zhuxunserver/sms/authCode";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- LOG(@"\n\nappHost: %@\n\n",APP_HOST);
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData, nil);
- }else{
- block(nil, error);
- }
- }];
-
- }
- //请求通知公告提醒--ok
- -(void)request_NoticeOffline_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/zx/notice/offline";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData,nil);
- }else{
- block(nil,error);
- }
-
- }];
- }
- -(void) request_with:(NetworkMethod)method andUrl:(NSString *)url andPrams:(id)params andBlock:(void (^)(id))block
- {
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:url withParams:params withMethodType:method andBlock:^(id data, NSError *error) {
-
- if(error){
- // 提示
- return;
- }
-
- id resultData = [data valueForKeyPath:@"data"];
- block(resultData);
- }];
-
- }
- //获取离线消息--废弃
- -(void)request_MsgOffLine_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
- {
- NSString *path = @"/v1/msg/offline";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- id resultData = [data valueForKeyPath:@"data"];
- if (resultData) {
- block(resultData,nil);
- }else{
- block(nil,error);
- }
-
- }];
- }
- //获取历史消息--废弃
- -(void)request_HistoryMessage_WithParams:(id)params andBlock:(void(^)(id data ,NSError *error))block
- {
- //history
- NSString *path = @"/v1/msg/sync";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
-
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
- }
- block(result,nil);
-
-
- }];
- }
- //获取发送者离线同步消息 /v1/msg/offlinesync 自己在PC发送的消息
- -(void)request_MsgOffLinesync_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/v1/msg/offlinesync";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
-
- }
- block(result,nil);
- }];
- }
- /**
- * 统一获取离线消息--废弃
- *
- * @param params
- * @param block
- */
- -(void)request_MsgOffLinesMsgsParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- /*
- 参数说明:
- String target -必填项,目标用户,格式:CID+serverID-loginName
- String uuid -可选项,请求唯一标识
- 参数格式: { target : "0578+serverID-loginName", uuid:""
- */
- NSString *path = @"/v1/msg/offlineFull";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
-
- }
- block(result,nil);
- }];
- }
- /**
- * 离线消息获取并反馈成功接口--废弃
- *
- * @param params
- * @param block
- */
- -(void)request_MsgOffLinesMsgsReceiveResponse:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- /*
- 参数说明:
- Array uuids -必填项,拉取的数据唯一标识uuid数组,示例:['111','222']
- String target -可选项,目标用户,格式:CID+serverID-loginName
- String uuid -可选项,请求唯一标识
- 参数格式: { uuids:['111','222'], target : "0578+serverID-loginName", uuid:"" }
- */
- NSString *path = @"/v1/msg/receivedFull";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
-
- }
- block(result,nil);
- }];
-
- }
- /**
- * 用户最近联系人列表(只含有未读消息)--ok
- *
- * @param params id
- * @param block return
- */
- - (void)request_UnReadMsgListWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/v1/user/unread";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
-
- }
- block(result,nil);
- }];
- }
- /**
- * 获取单人聊天历史纪录--ok
- *
- * @param params id
- * @param block return
- */
- //- (void)request_SingleUnReadMsgsWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- //{
- // NSString *path = @"/v1/msg/offlineSimple";
- // NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- // //对params中的参数进行二次校验,符合继续不符合return;@"0578+(null)"
- // if ([[params objectForKey:@"target"] isEqualToString:[NSString stringWithFormat:@"%@+(null)",[userDefaults objectForKey:USERDEFAULT_ContentServer]]] ) {
- // return;
- // }
- // [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- // if(error){
- // //用户提示;
- // return;
- // }
- // NSLog(@"%@",data[@"message"]);
- // BOOL success = data[@"success"];
- // id result = nil;
- // if (success) {
- // result = data[@"data"];
- //
- // }
- // block(result,nil);
- // }];
- //}
- /**
- * 获取单人聊天历史纪录成功的反馈--废弃
- *
- * @param params id
- 参数说明:
- String current -必填项,当前用户,格式:CID+serverID-loginName
- String target -必填项,目标用户,格式:CID+serverID-loginName
- String|int time -必填项,拉取的消息中最新的消息时间戳,Number类型
- String uuid -可选项,请求唯一标识
- 参数格式:{ current:"CID+serverID-loginName", target:"CID+serverID-loginName", time:123455678.45, uuid:"" }
- * @param block return
- */
- - (void)request_SingleUnReadMsgsResponseWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/v1/msg/receivedSimple";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- if(error){
- //用户提示;
- return;
- }
- NSLog(@"%@",data[@"message"]);
- BOOL success = data[@"success"];
- id result = nil;
- if (success) {
- result = data[@"data"];
-
- }
- block(result,nil);
- }];
- }
- //获取单对单历史消息--废弃
- -(void)request_chatObjectHistory_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/v2/msg/history";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
-
- return ;
- }
-
- BOOL success = data[@"success"];
-
- id result = nil;
- if (success) {
- result = data[@"data"];
- }
- block(result,nil);
-
- }];
- }
- -(void)public_Request_With_MethodType:(RequestMethod)method path:(NSString *)path params:(id)params andBlock:(void (^) (id data, NSError *error))block{
-
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
-
- if (!error) {
-
- id resultData = [data valueForKey:@"data"];
- block(data,nil);
- }else{
-
- block(nil,error);
-
- }
-
-
- }];
-
- }
- //拉取设备比对--ok
- -(void)request_User_lastDevice_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block{
-
- NSString *path = @"/v1/user/lastDevice";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- BOOL success = [data[@"success"] boolValue];
-
- if (success) {
- block(data,nil);
- }else{
- if (error) {
- block(nil,error);
- }
- }
-
- }];
-
- }
- //微助手自带短信--ok
- -(void)request_SendSMS_NoLocalWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- {
- NSString *path = @"/zhuxunserver/sms/send";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- BOOL success = data[@"success"];
-
- if (success) {
-
- block(data,nil);
-
- }else{
-
- block(nil,error);
-
- }
-
- }];
- }
- //删除用户聊天信息--ok
- -(void)request_deleteCurrentChatMessagesWithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/msg/delete";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- //注销登录 -- 0k
- - (void)logout_withParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/user/logout";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- //获取我的客服
- - (void)getMyCustomerServicerwithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/customerService";
-
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- // 获取我的常用联系人
- - (void)getMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- ///v1/frequentContact
- NSString *path = @"/v1/frequentContact";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- // 添加我的常用联系人
- - (void)addMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/frequentContact";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- // 删除我的常用联系人
- - (void)deleteMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
- NSString *path = @"/v1/frequentContact";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Delete andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- //获取顶级部门成员--OK
- - (void)postTopDepartmentMembers:(id)params andBlock:(void (^)(id data,NSError *error))block
- {
-
- NSString *path = @"/zhuxunserver/branchs/getMyTopBranch";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
-
- if (error) {
- block(nil,error);
- }else{
- block(data,nil);
- }
- }];
- }
- //==========socket.io 模拟的http
- //通过传入的请求服务器命令和 sender 获取离线同步消息
- -(void)request_isSync_WithParams:(id)params andBlock:(void (^)(id, NSError *))block{
-
- NSString *path = @"/zhuxunserver.chat.message.sync";
- NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
-
- [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
- id result = [data valueForKey:@"data"];
- if (result) {
- block(result,nil);
- }else{
- block(nil,error);
- }
- }];
-
- }
- //-(void)request_login_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- //{
- // LoginAPI *loginAPI = [LoginAPI new];
- // [loginAPI requestWithObject:params Completion:^(id response, NSError *error) {
- //
- // //登录信息回调
- // block(response, nil);
- //
- // }];
- //}
- //通过用户的登录名和密码等 认证用户并获取离线消息
- //-(void)request_auth_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
- //{
- // AuthAPI *loginApi = [[AuthAPI alloc]init];
- // loginApi.noNeedSendAgain = YES;
- // //将获取的离线消息数据回调
- // [loginApi requestWithObject:params Completion:^(id response, NSError *error) {
- //// if (error) {
- //// return ;
- //// }
- // //Error Domain=请求超时 Code=1001 "(null)"
- // block(response, error);
- // }];
- //}
- -(BOOL)isNull:(NSDictionary*) data{
- return (!data || [data isKindOfClass:[NSNull class]]);
- }
- -(void)alertWithMessage:(NSString *)msg
- {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
-
- [alertView show];
- }
- @end
|