add files apis
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// GiGaBaseAPiRequest.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/8/29.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "GiGaAPIResult.h"
|
||||
|
||||
typedef NS_ENUM(NSInteger, GIGARequestStatus) {
|
||||
NotAvailable = 1, //不可用
|
||||
RequestSuccess = 2, //请求成功
|
||||
RequestFailed = 4, //请求失败
|
||||
RequestLocalData = 8, //本地请求
|
||||
RequestNoMoreContent = 16, //没有更多数据
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, GIGARequestNetStatus) {
|
||||
|
||||
NetStatusWifi = 1,
|
||||
NetStatusWWAN = 2,
|
||||
NetStatusUnKown= 4,//不可用
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, RequestMethod) {
|
||||
RequestPostMethod = 1, //post 请求
|
||||
RequestGetMethod = 2, //get 请求
|
||||
RequestPutMethod = 3, //put 请求
|
||||
RequestDelMethod = 4, //del 请求
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger ,GiGAErrorCode){
|
||||
GiGAErrorCode_SUCCESS = 0,//成功
|
||||
GiGAErrorCode_USER_EXIST = 500,//用户已存在
|
||||
|
||||
};
|
||||
|
||||
@class GiGaBaseAPiRequest;
|
||||
|
||||
typedef void (^GiGaRequestResultBlock)(GiGaAPIResult *result);
|
||||
|
||||
@interface GiGaBaseAPiRequest : NSObject
|
||||
|
||||
#pragma mark - porperty
|
||||
|
||||
@property (nonatomic,assign) GIGARequestNetStatus statu;
|
||||
|
||||
//@property (nonatomic, copy) GIGARequestSuccessBlock successBlock;
|
||||
//@property (nonatomic, copy) GIGARequetFailBlock failBlock;
|
||||
@property (nonatomic,copy) GiGaRequestResultBlock blockresult;
|
||||
|
||||
/** 请求类型 */
|
||||
@property (nonatomic, assign) RequestMethod requestMethod;
|
||||
/** 请求超时时间 */
|
||||
@property (nonatomic, readonly) NSTimeInterval timeout;
|
||||
/** 服务器地址 */
|
||||
@property (nonatomic, readonly) NSString *serviceUrl;
|
||||
/** 请求路径 */
|
||||
@property (nonatomic, copy) NSString *fullUrl;
|
||||
|
||||
/** 请求参数 */
|
||||
@property (nonatomic, strong) NSMutableDictionary *params;
|
||||
|
||||
/**
|
||||
* 请求得到的全部数据
|
||||
*/
|
||||
@property (strong, nonatomic) NSDictionary *resultDict;
|
||||
|
||||
@property (strong, nonatomic) NSDictionary *responseHeaderFields;
|
||||
|
||||
@property (nonatomic, assign) BOOL needToken; // 是否需要带上token
|
||||
|
||||
/**
|
||||
* 检查网络
|
||||
*/
|
||||
- (void)checkNetwork;
|
||||
|
||||
|
||||
/**
|
||||
发起请求
|
||||
|
||||
@param result 。
|
||||
*/
|
||||
- (void)requstDataWithResult:(GiGaRequestResultBlock)result;
|
||||
|
||||
|
||||
/**
|
||||
* 发起本地存储数据请求
|
||||
*
|
||||
* @param success 成功block
|
||||
* @param failure 失败block
|
||||
*/
|
||||
//- (void)loadLocalDataAsyncWithSuccess:(GIGARequestSuccessBlock)success
|
||||
// failure:(GIGARequetFailBlock)failure;
|
||||
/**
|
||||
* 分析错误信息
|
||||
*
|
||||
* @param requestDict 服务器返回数据
|
||||
* @param error error信息
|
||||
*/
|
||||
- (void)analyseResponseInfo:(NSDictionary *)requestDict error:(NSError *)error;
|
||||
|
||||
- (void)analyseResponseInfo:(NSDictionary *)requestDict
|
||||
headerFileds:(NSDictionary *)headerFields
|
||||
error:(NSError *)error;
|
||||
|
||||
|
||||
/**
|
||||
API convenience constructor
|
||||
@param path request path
|
||||
@param method method
|
||||
@param parms parms
|
||||
@return model
|
||||
*/
|
||||
+ (instancetype)initWithRequestPath:(NSString *)path
|
||||
method:(RequestMethod)method
|
||||
parms:(NSDictionary *)parms;
|
||||
|
||||
+ (instancetype)initWithRequestAbsoluteURLString:(NSString *)absoluteString
|
||||
method:(RequestMethod)method
|
||||
parms:(NSDictionary *)parms;
|
||||
|
||||
//+ (instancetype)uploadImage:(NSString *)url
|
||||
// imgData:(NSData *)imgData
|
||||
// parms:(NSDictionary *)parms
|
||||
// success:(GIGARequestSuccessBlock)success
|
||||
// failure:(GIGARequetFailBlock)failure;
|
||||
|
||||
//+ (NSString *)resizeImageUrl:(NSString *)originImageUrl
|
||||
// size:(CGSize)size;
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user