Commit a433ae95 authored by 汪洋's avatar 汪洋

删除没有必要的新代码

parent 1e9fea67
......@@ -34,24 +34,6 @@
@property (nonatomic, strong) NSString *urlCommonParameters;
+ (instancetype)shareInstance;
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseJSON:(nullable void (^)(NSDictionary * _Nullable dic, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed;
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseList:(nullable void (^)(NSArray * _Nullable data, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed;
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseString:(nullable void (^)(NSString * _Nullable string, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed;
/**
* @author licong, 15-11-19 12:11:09
*
......
......@@ -23,71 +23,6 @@
return instance;
}
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseJSON:(nullable void (^)(NSDictionary * _Nullable dic, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed {
[self send:URLString parameters:parameters method:method responseList:success failed:failed];
}
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseList:(nullable void (^)(NSArray * _Nullable data, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed {
[self send:URLString parameters:parameters method:method responseList:success failed:failed];
}
+ (void)sendRequestWithURLString:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseString:(nullable void (^)(NSString * _Nullable string, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed {
[self send:URLString parameters:parameters method:method responseList:success failed:failed];
}
+ (void)send:(NSString *)URLString
parameters:(nullable id)parameters
method:(HttpMethod)method
responseList:(nullable void (^)(id _Nullable data, NSString * _Nullable message, APIStatusCode error))success
failed:(nullable ResultFailed)failed {
void (^AFSuccess) (NSURLSessionDataTask *task, id responseObject) = ^(NSURLSessionDataTask *task, id responseObject) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
success(responseObject[@"data"], responseObject[@"message"], [responseObject[@"error"] integerValue]);
};
void (^AFFailure) (NSURLSessionDataTask *task, NSError *error) = ^(NSURLSessionDataTask *task, NSError *error) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response;
NSURLRequest *request = task.originalRequest;
NSInteger statusCode = response.statusCode;
NSString *errorStr = [NSString stringWithFormat:@"%@ %ld: %@ %@",request.URL.path, (long)statusCode, [error localizedFailureReason], [error localizedDescription]];
if(statusCode == HttpStatusCodeUnauthorized){
[[NSNotificationCenter defaultCenter] postNotificationName:[WMNetService shareInstance].loginExpiredName object:nil];
}else {
debugLog(@"WMNetService %@", errorStr);
}
failed(errorStr);
};
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString *resultURLString = [URLString stringByAppendingString:[WMNetService shareInstance].urlCommonParameters];
if (method == HttpMethodGet) {
[[WMNetService shareInstance].networking GET:resultURLString parameters:parameters success:AFSuccess failure:AFFailure];
}else if (method == HttpMethodPost){
[[WMNetService shareInstance].networking POST:resultURLString parameters:parameters success:AFSuccess failure:AFFailure];
}else if (method == HttpMethodDelete){
[[WMNetService shareInstance].networking DELETE:resultURLString parameters:parameters success:AFSuccess failure:AFFailure];
}else if (method == HttpMethodPatch){
[[WMNetService shareInstance].networking PATCH:resultURLString parameters:parameters success:AFSuccess failure:AFFailure];
}else if (method == HttpMethodPut){
[[WMNetService shareInstance].networking PUT:resultURLString parameters:parameters success:AFSuccess failure:AFFailure];
}
}
#pragma mark - Method Decrepeted
- (void)sendRequestWithURLString:(NSString *)URLString
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment