RYBaseVM.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // RYBaseVM.h
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/12/25.
  6. //
  7. #import <Foundation/Foundation.h>
  8. typedef NS_ENUM(NSUInteger,ReqNetType){
  9. GetReqNetType ,
  10. PostReqNetType ,
  11. FormDataPostReqNetType ,
  12. PutReqNetType ,
  13. DeleteReqNetType
  14. } ;
  15. NS_ASSUME_NONNULL_BEGIN
  16. @protocol RY_baseVMprotocol <NSObject>
  17. ///获取网络请求的回调
  18. -(void)ry_respnsData:(nullable id)data
  19. parseAry:(nullable NSMutableArray *)arry
  20. sucess:(BOOL)sucessOrFail
  21. mark:(NSString *)mark
  22. reqNetType:(ReqNetType)reqNetType;
  23. ///batch 多个 网络请求同步的代理
  24. ///同步时发出了a、b、c 3个网络请求,我们希望在a、b、c 3个网络请求都结束的时候获得一个通知
  25. //-(void)pro_batchResponAry:(NSArray <UCMHttpRequestResponse *>*)responseAry success:(BOOL)success modelData:(NSMutableArray *_Nullable)modelAry;
  26. @end
  27. @interface RYBaseVM : NSObject
  28. @property (nonatomic, weak) id <RY_baseVMprotocol> delegate;
  29. + (instancetype)setupVMclass:(Class)VMclass;
  30. - (instancetype)initDelegate:(id<RY_baseVMprotocol>)delegte;
  31. -(void)ry_requestPostApi:(NSString *)mark param:(NSDictionary *)param;
  32. -(void)ry_formDataRequestPostApi:(NSString *)mark param:(NSDictionary *)param;
  33. -(void)ry_requestGetApi:(NSString *)mark param:(NSDictionary *)param;
  34. -(void)ry_requestPutApi:(NSString *)mark param:(NSString *)paramStr;
  35. -(void)ry_requestDeleteApi:(NSString *)mark paramStr:(NSString *)paramStr;
  36. //重写的方法 解析之后再传给 VC
  37. -(void)ry_respnsSucessWithPath:(NSString *)mark data:(id)data reqNetType:(ReqNetType)reqNetType;
  38. -(void)ry_reponsFaildWithPath:(NSString *)mark code:(NSString *)code msg:(NSString *)msg reqNetType:(ReqNetType)reqNetType;
  39. - (void)ry_VMconfigDelegateData:(id)data
  40. parseAry:(NSMutableArray *)ary
  41. success:(BOOL)success
  42. mark:(NSString *)mark
  43. reqNetType:(ReqNetType)reqNetType;
  44. @end
  45. NS_ASSUME_NONNULL_END