| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820 |
- //
- // KSNetworkingManager.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/17.
- //
- #import "KSNetworkingManager.h"
- #import "KeyChainTools.h"
- #import "LoginViewController.h"
- #import "AppDelegate.h"
- #import <RongIMKit/RongIMKit.h>
- #import "JPUSHService.h"
- #import "RCConnectionManager.h"
- #import "CustomNavViewController.h"
- @implementation KSNetworkingManager
- + (void)configRequestHeader {
- if (![NSString isEmptyString:UserDefault(TokenKey)]) {
- [[VoNetworking sharedManager] configHttpHeader:@{@"Authorization":[NSString stringWithFormat:@"%@ %@", UserDefault(Token_type), UserDefault(TokenKey)]}];
- }
- }
- + (void)configRequestFormHeaderWithToken:(NSString *)token {
- if (![NSString isEmptyString:token]) {
- [[VoNetworking sharedManager] configHttpHeader:@{@"Authorization":[NSString stringWithFormat:@"%@ %@", UserDefault(Token_type), token], @"Content-Type":@"application/x-www-form-urlencoded"}];
- }
- else if (![NSString isEmptyString:UserDefault(TokenKey)]) {
- [[VoNetworking sharedManager] configHttpHeader:@{@"Authorization":[NSString stringWithFormat:@"%@ %@", UserDefault(Token_type), UserDefault(TokenKey)], @"Content-Type":@"application/x-www-form-urlencoded"}];
- }
- else {
- [[VoNetworking sharedManager] configHttpHeader:@{@"Content-Type":@"application/x-www-form-urlencoded"}];
- }
- }
- + (void)clearRequestHeader {
- [[VoNetworking sharedManager] removeHeaderKey];
- }
- // 设置表单提交方式
- + (void)configRequestMethodForm {
- [VoNetworking sharedManager].httpSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
- [self configRequestFormHeaderWithToken:nil];
- }
- + (void)configRequestMethodFormWithToken:(NSString *)token {
- [VoNetworking sharedManager].httpSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer];
- [self configRequestFormHeaderWithToken:token];
- }
- // 设置json提交方式
- + (void)configRequestMethodJSON {
- [VoNetworking sharedManager].httpSessionManager.requestSerializer = [AFJSONRequestSerializer serializer];
- [self configRequestHeader];
- }
- + (NSString *)returnNoContainGroupId:(NSString *)groupId {
- if (![NSString isEmptyString:groupId]) {
- if ([groupId containsString:@"S"] || [groupId containsString:@"I"]) {
- groupId = [groupId substringFromIndex:1];
- }
- }
- return groupId;
- }
- /**
- * 封装网络请求
- */
- + (void)request:(NSString *)post andWithUrl:(NSString *)myUrl and:(id)parm success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- __block NSDictionary *dic;
- #pragma mark ----- 签名
- // parm = [NSString signToMD5:parm];
- NSLog(@"%@",[parm mj_JSONString]);
- // post
- if ([post isEqualToString:KS_POST]) {
- [[VoNetworking sharedManager] postWithUrl:myUrl refreshRequest:YES cache:NO params:parm progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
-
- NSLog(@"%lld--%lld",bytesRead,totalBytes);
-
- } successBlock:^(id response) {
-
- dic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
-
- if ([dic integerValueForKey:@"code"] == 403) { // token验证失败
- [self logOutWithType:YES];
- return ;
- }
- else if ([dic integerValueForKey:@"code"] == 401) {
- [self logOutWithType:NO];
- return ;
- }
- success(dic);
- return ;
-
- } failBlock:^(NSError *error) {
- NSLog(@"%@",error.description);
- faliure(error);
- if (error.code == -1001) {
- [self showMessage:@"网络请求超时"];
- }
- else if (error.code != -999) {
- [self showMessage:@"网络或服务器错误,请重试"];
- }
-
- }];
- }
- // get
- else {
- [[VoNetworking sharedManager] getWithUrl:myUrl refreshRequest:YES cache:NO params:parm progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
-
- NSLog(@"%lld--%lld",bytesRead,totalBytes);
-
- } successBlock:^(id response) {
-
- dic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
-
- if ([dic integerValueForKey:@"code"] == 403) { // token验证失败
- [self logOutWithType:YES];
- return;
- }
- else if ([dic integerValueForKey:@"code"] == 401) {
- [self logOutWithType:NO];
- return;
- }
- success(dic);
- return ;
-
- } failBlock:^(NSError *error) {
- NSLog(@"%@",error.description);
- faliure(error);
- if (error.code == -1001) {
- [self showMessage:@"网络请求超时"];
- }
- else if (error.code != -999) {
- [self showMessage:@"网络或服务器错误,请重试"];
- }
-
- }];
- }
- }
- + (void)logOutWithType:(BOOL)isDisable {
- // 移除所有的loadView
- [[VoNetworking sharedManager] cancleAllRequest];
- [MBProgressHUD hideHUD];
- if (isDisable) {
- [self showMessage:@"登录过期,请重新登录"];
- }
- else {
- [self showMessage:@"未认证"];
- }
- [self logoutAction];
- }
- + (void)logoutAction {
- [self clearRequestHeader];
- // 取消推送别名
- [JPUSHService deleteAlias:nil seq:0];
- // 清除数据信息
- UserDefaultRemoveObjectForKey(TokenKey);
- UserDefaultRemoveObjectForKey(RongTokenKey);
- [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
- [RCConnectionManager shareManager].isNeedJoin = NO;
- [RCConnectionManager shareManager].isNeedShowMessage = NO;
- [[RCIM sharedRCIM] logout];
- // 回到登录界面
- UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
- if ([vc.presentedViewController isKindOfClass:NSClassFromString(@"NewClassroomViewController")]) {
- [[NSNotificationCenter defaultCenter] postNotificationName:@"classroomLogout" object:nil];
- }
- else if ([vc isKindOfClass:[UITabBarController class]]) {
- UITabBarController *tab = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
- CustomNavViewController *ctrl = (CustomNavViewController *)tab.selectedViewController;
- [ctrl popToRootViewControllerAnimated:NO];
- LoginViewController *logonVC = [[LoginViewController alloc] init];
- CustomNavViewController *navCtrl = [[CustomNavViewController alloc] initWithRootViewController:logonVC];
- navCtrl.modalPresentationStyle = UIModalPresentationFullScreen;
- [tab.selectedViewController presentViewController:navCtrl animated:YES completion:nil];
- }
- }
- // 提示信息
- + (void)showMessage:(NSString *)message {
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication].windows lastObject] animated:YES];
- hud.removeFromSuperViewOnHide =YES;
- hud.mode = MBProgressHUDModeText;
- hud.label.text = message;
- hud.minSize = CGSizeMake(132.f, 60.0f);
- hud.label.textColor = [UIColor whiteColor];
- hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
- hud.bezelView.backgroundColor = [UIColor colorWithHexString:@"#000000" alpha:0.8];
- [hud hideAnimated:YES afterDelay:2];
- }
- // 多文件上传
- + (void)uploadMultiFileWithFileArray:(NSArray *)datas
- andWithUrl:(NSString *)myUrl
- parameters:(NSDictionary *)parameters
- type:(NSString *)type
- name:(NSString *)name
- mimeType:(NSString *)mimeType
- progress:(void(^)(NSProgress * _Nonnull uploadProgress))progress
- success:(void(^)(NSMutableArray *dics))success
- faliure:(void(^)(NSError *error))faliure {
-
- __block NSMutableArray *dics = [NSMutableArray array];
- [[VoNetworking sharedManager] uploadMultFileWithUrl:myUrl parameters:parameters fileDatas:datas type:type name:name mimeType:mimeType progressBlock:^(int64_t bytesWritten, int64_t totalBytes) {
-
- } successBlock:^(NSArray *responses) {
- for (id response in responses) {
- NSDictionary *subDic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
- [dics addObject:subDic];
- }
- success(dics);
- } failBlock:^(NSArray *errors) {
- [self showMessage:@"网络或服务器错误,请重试"];
- faliure([errors lastObject]);
- }];
-
- }
- // 单文件上传
- + (void)uploadFileWithFileData:(NSData *)data
- andWithUrl:(NSString *)myUrl
- parameters:(NSDictionary *)parameters
- type:(NSString *)type
- name:(NSString *)name
- mimeType:(NSString *)mimeType
- progress:(void(^)(int64_t bytesWritten,
- int64_t totalBytes))progress
- success:(void(^)(NSDictionary *dic))success
- faliure:(void(^)(NSError *error))faliure {
-
- __block NSDictionary *dic;
- [[VoNetworking sharedManager] uploadFileWithUrl:myUrl parameters:parameters fileData:data type:type name:name mimeType:mimeType progressBlock:^(int64_t bytesWritten, int64_t totalBytes) {
- if (progress) {
- progress(bytesWritten, totalBytes);
- }
- } successBlock:^(id response) {
-
- dic = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];
- success(dic);
- return ;
- } failBlock:^(NSError *error) {
- faliure(error);
- [self showMessage:@"网络或服务器错误,请重试"];
- }];
- }
- // 下载
- + (void)downloadTaskWithUrl:(NSString *)myUrl
- progress:(void(^)(int64_t bytesRead, int64_t totalBytes))progress
- success:(void(^)(NSURL *fileUrl))success
- faliure:(void(^)(NSError *error))faliure {
- [self clearRequestHeader];
- [[VoNetworking sharedManager] downloadWithUrl:myUrl progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
- if (progress) {
- progress(bytesRead, totalBytes);
- }
- } successBlock:^(NSURL * _Nullable url) {
- [self configRequestHeader];
- if (success) {
- success(url);
- }
- } failBlock:^(NSError * _Nonnull error) {
- if (faliure) {
- faliure(error);
- }
- [self showMessage:@"网络或服务器错误,请重试"];
- [self configRequestHeader];
- }];
- }
- // 多文件下载
- + (void)mutilDownTaskWithUrl:(NSArray *)urlArray
- progress:(void(^)(int64_t bytesRead, int64_t totalBytes))progress
- successBlock:(void(^)(NSMutableArray *dics))success
- failBlock:(void(^)(NSError *error))faliure {
- [self clearRequestHeader];
- [[VoNetworking sharedManager] downloadMutilFileWithUrl:urlArray progressBlock:^(int64_t bytesRead, int64_t totalBytes) {
-
- } successBlock:^(NSArray * _Nonnull responses) {
- [self configRequestHeader];
- NSMutableArray *result = [NSMutableArray arrayWithArray:responses];
- success(result);
- } failBlock:^(NSArray * _Nonnull errors) {
- [self showMessage:@"网络或服务器错误,请重试"];
- [self configRequestHeader];
- faliure([errors lastObject]);
- }];
- }
- #pragma mark ---- 图片上传
- /**
- 图片上传
-
- @param post post
- @param pics 图片的数组
- @param success 成功
- @param faliure 失败
- */
- + (void)multiImageUpload:(NSString *)post imgDataArray:(NSArray *)pics success:(void(^)(NSArray *dics))success faliure:(void(^)(NSError *error))faliure {
- NSString* url = [NSString stringWithFormat:@"%@%@",hostURL,@"/api-student/uploadFile"];
- NSString *type = [UIImage typeForImageData:[pics lastObject]];
- [self uploadMultiFileWithFileArray:pics andWithUrl:url parameters:nil type:type name:@"file" mimeType:[NSString stringWithFormat:@"Image/%@",type] progress:nil success:success faliure:faliure];
- }
- #pragma mark ----- 视频文件上传
- /**
- 视频文件上传
- @param post post
- @param fileData 文件data
- @param progress 进度
- @param success 成功
- @param faliure 失败
- */
- + (void)videoFileUpload:(NSString *)post fileData:(NSData *)fileData progress:(void(^)(int64_t bytesWritten,int64_t totalBytes))progress success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure; {
- [self configRequestMethodJSON];
- NSString* url = [NSString stringWithFormat:@"%@%@",hostURL,@"/api-student/uploadFile"];
-
- [self uploadFileWithFileData:fileData andWithUrl:url parameters:nil type:@".mp4" name:@"file" mimeType:[NSString stringWithFormat:@"Image/.mp4"] progress:progress success:success faliure:faliure];
- }
- #pragma mark ---- 文件下载
- + (void)downloadFileRequestWithFileUrl:(NSString *)url progress:(void (^)(int64_t, int64_t))progress success:(void (^)(NSURL * _Nonnull))success faliure:(void (^)(NSError * _Nonnull))faliure {
- [self downloadTaskWithUrl:url progress:progress success:success faliure:faliure];
- }
- + (void)mutiDownloadFileRequest:(NSArray *)fileUrl progress:(void (^)(int64_t, int64_t))progress success:(void (^)(NSArray * _Nonnull))success faliure:(void (^)(NSError * _Nonnull))faliure {
- [self mutilDownTaskWithUrl:fileUrl progress:progress successBlock:success failBlock:faliure];
- }
- #pragma mark ----- 登录相关
- + (void)LoginRequest:(NSString *)post phone:(NSString *)phone password:(NSString *)password success:(void (^)(NSDictionary * _Nonnull))success faliure:(void (^)(NSError * _Nonnull))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:@"student" forKey:@"clientId"];
- [parm setValue:@"student" forKey:@"clientSecret"];
- [parm setValue:phone forKey:@"username"];
- [parm setValue:password forKey:@"password"];
- [parm setValue:[KeyChainTools getUUID] forKey:@"deviceNum"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL,@"/api-auth/usernameLogin"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/smsLogin
- /**
- 验证码登录/注册
-
- @param post post
- @param phone 手机号
- @param smsCode 验证码
- @param success 成功
- @param faliure 失败
- */
- + (void)smsLoginRequest:(NSString *)post phone:(NSString *)phone smsCode:(NSString *)smsCode success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:@"student" forKey:@"clientId"];
- [parm setValue:@"student" forKey:@"clientSecret"];
- [parm setValue:phone forKey:@"phone"];
- [parm setValue:smsCode forKey:@"smsCode"];
- [parm setValue:@"IOS" forKey:@"channel"];
- [parm setValue:@"true" forKey:@"isSurportRegister"];
- [parm setValue:[KeyChainTools getUUID] forKey:@"deviceNum"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL,@"/api-auth/smsLogin"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/refreshToken
- /**
- 刷新token的逻辑
-
- @param post post
- @param success 成功
- @param faliure 失败
- */
- + (void)refreshTokenRequest:(NSString *)post success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- [self clearRequestHeader];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:@"student" forKey:@"clientId"];
- [parm setValue:@"student" forKey:@"clientSecret"];
- [parm setValue:UserDefault(RefreshToken) forKey:@"refreshToken"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/refreshToken"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
-
- }
- // /api-auth/checkToken
- /// 校验token是否有效
- /// @param get get
- /// @param success 成功
- /// @param faliure 失败
- + (void)checkTokenRequest:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/checkToken"];
- [self request:get andWithUrl:url and:nil success:success faliure:faliure];
- }
- // 接口地址 /api-auth/user/setUsernameAndPassword
- /**
- 设置密码
-
- @param post post
- @param username 用户名
- @param password 密码
- @param token token
- @param success 成功
- @param faliure 失败
- */
- + (void)setPasswordRequest:(NSString *)post username:(NSString *)username password:(NSString *)password token:(NSString *)token success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodFormWithToken:token];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:username forKey:@"username"];
- [parm setValue:password forKey:@"password"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/setUsernameAndPassword"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/user/updatePassword
- /**
- 修改密码
-
- @param post post
- @param authCode 验证码
- @param mobile 手机号
- @param newPassword 新密码
- @param success 成功
- @param faliure 失败
- */
- + (void)updatePasswordRequest:(NSString *)post authCode:(NSString *)authCode mobile:(NSString *)mobile newPassword:(NSString *)newPassword success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:mobile forKey:@"mobile"];
- [parm setValue:authCode forKey:@"authCode"];
- [parm setValue:newPassword forKey:@"newPassword"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/updatePassword"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/user/checkUser
- /// 用户信息校验
- /// @param get get
- /// @param phone 手机号
- /// @param password 密码
- /// @param success 成功
- /// @param faliure 失败
- + (void)checkUserRequest:(NSString *)get phone:(NSString *)phone password:(NSString *)password success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
-
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/checkUser"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:phone forKey:@"phone"];
- [parm setValue:password forKey:@"password"];
- [self request:get andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/user/updatePhone
- /// 修改手机号
- /// @param post post
- /// @param oldPhone 旧手机号
- /// @param authCode 验证码
- /// @param newPhone 新手机号码
- /// @param success 成功
- /// @param faliure 失败
- + (void)updatePhoneRequest:(NSString *)post oldPhone:(NSString *)oldPhone authCode:(NSString *)authCode newPhone:(NSString *)newPhone success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/updatePhone"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:oldPhone forKey:@"oldPhone"];
- [parm setValue:authCode forKey:@"authCode"];
- [parm setValue:newPhone forKey:@"newPhone"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/user/refreshImToken
- /// 刷新IM token
- /// @param post post
- /// @param success 成功
- /// @param faliure 失败
- + (void)refreshImTokenRequest:(NSString *)post success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/refreshImToken"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/exit
- /**
- 退出登录
-
- @param post 请求
- @param success 成功
- @param faliure 失败
- */
- + (void)logoutRequest:(NSString *)post success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/exit"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/subject/subjectSelect
- /// 声部信息查询 (树状列表)
- /// @param get get
- /// @param success 成功
- /// @param faliure 失败
- + (void)studentQuerySubject:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- NSString *url = [NSString stringWithFormat:@"%@%@", hostURL, @"/api-student/subject/subjectSelect"];
- [self request:get andWithUrl:url and:nil success:success faliure:faliure];
- }
- // /api-student/student/setSubject
- /// 设置声部
- /// @param get get
- /// @param subjectIds 声部id
- /// @param success 成功
- /// @param faliure 失败
- + (void)studentSetSubject:(NSString *)get subjectIds:(NSString *)subjectIds success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/student/setSubject"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:subjectIds forKey:@"subjectIds"];
- [self request:get andWithUrl:url and:parm success:success faliure:faliure];
- }
- #pragma mark ---- 验证码服务
- // /api-student/code/sendSms
- /**
- 发送短信验证码
-
- @param post post
- @param mobile 手机号码
- @param success 成功
- @param faliure 失败
- */
- + (void)sendSmsRequest:(NSString *)post mobile:(NSString *)mobile success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:mobile forKey:@"mobile"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/code/sendSmsCode"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/code/verifyImageCode
- /**
- 图形验证码校验
-
- @param post post
- @param phone 手机号
- @param code 验证码
- @param success 成功
- @param faliure 失败
- */
- + (void)verifyLoginImageRequest:(NSString *)post phone:(NSString *)phone code:(NSString *)code success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodForm];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:phone forKey:@"phone"];
- [parm setValue:code forKey:@"code"];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/code/verifyImageCode"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- #pragma mark ----- 查询用户信息
- // /api-auth/queryUserInfo
- /**
- 获取个人信息
-
- @param get get
- @param success 成功
- @param faliure 失败
- */
- + (void)queryUserInfo:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/api/queryUserInfo"];
- [self request:get andWithUrl:url and:nil success:success faliure:faliure];
- }
- // /api-student/Student/queryUserInfo
- /// 查询学生信息
- /// @param get get
- /// @param success 成功
- /// @param faliure 失败
- + (void)queryStudentInfoRequest:(NSString *)get success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/student/queryUserInfo"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [self request:get andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-auth/user/submitSetDetail
- /// 修改用户信息
- /// @param post post
- /// @param avatal 头像
- /// @param gender 性别
- /// @param username 昵称
- /// @param success 成功
- /// @param faliure 失败
- + (void)modifyUserMessage:(NSString *)post avatal:(NSString *)avatal gender:(NSString *)gender username:(NSString *)username success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/submitSetDetail"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:avatal forKey:@"avatar"];
- [parm setValue:gender forKey:@"gender"];
- [parm setValue:username forKey:@"username"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- #pragma mark -------- 群组服务
- // /api-student/imUserFriend/queryAll
- /// 查询好友列表
- /// @param post post
- /// @param search 搜索
- /// @param success 成功
- /// @param faliure 失败
- + (void)imUserFriendRequest:(NSString *)post search:(NSString *)search success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imUserFriend/queryAll"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:search forKey:@"search"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/imGroup/queryAll
- /// 查询老师群组列表
- /// @param post post
- /// @param search 搜索
- /// @param success 成功
- /// @param faliure 失败
- + (void)imGroupQueryPage:(NSString *)post search:(NSString *)search success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imGroup/queryAll"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:search forKey:@"search"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/imGroup/getDetail/{groupId}
- /// 获取群信息
- /// @param post post
- /// @param groupId 群id
- /// @param success 成功
- /// @param faliure 失败
- + (void)queryGroupDetail:(NSString *)post groupId:(NSString *)groupId success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@/%@",hostURL, @"/api-student/imGroup/getDetail",groupId];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // 获取群成员列表
- // /api-student/imGroupMember/queryAll
- /// 查询群成员列表
- /// @param post post
- /// @param groupId 群id
- /// @param success 成功
- /// @param faliure 失败
- + (void)imGroupMemberAllRequest:(NSString *)post groupId:(NSString *)groupId success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imGroupMember/queryAll"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:groupId forKey:@"groupId"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // 查询群成员
- // /api-student/imGroupMember/getUserDetail
- /// 查询群成员信息
- /// @param post post
- /// @param groupId 群id
- /// @param userId 用户id
- /// @param success 成功
- /// @param faliure 失败
- + (void)imGroupMemberQueryUser:(NSString *)post groupId:(NSString *)groupId userId:(NSString *)userId success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imGroupMember/getUserDetail"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:groupId forKey:@"groupId"];
- [parm setValue:userId forKey:@"userId"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // 获取IM好友详情
- // /api-student/imUserFriend/getDetail/{userId}
- /// 获取好友详情
- /// @param post post
- /// @param userId 用户id
- /// @param success 成功
- /// @param faliure 失败
- + (void)imUserFriendQueryDetail:(NSString *)post userId:(NSString *)userId success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@/%@",hostURL, @"/api-student/imUserFriend/getDetail",userId];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/imGroupMemberAudit/queryPage
- /// 申请入群列表
- /// @param post post
- /// @param groupId 群id
- /// @param success 成功
- /// @param faliure 失败
- + (void)imGroupMemberAuditListRequest:(NSString *)post groupId:(NSString *)groupId success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imGroupMemberAudit/queryPage"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:groupId forKey:@"groupId"];
- [parm setValue:@(1) forKey:@"page"];
- [parm setValue:@(200) forKey:@"rows"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- #pragma mark ---- 群公告
- // /api-student/imGroupNotice/queryPage
- /// 群公告列表查询
- /// @param post post
- /// @param groupId 群组id
- /// @param page 分页
- /// @param rows 条数
- /// @param success 成功
- /// @param faliure 失败
- + (void)queryNoticeListRequest:(NSString *)post groupId:(NSString *)groupId page:(NSString *)page rows:(NSString *)rows success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-student/imGroupNotice/queryPage"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:groupId forKey:@"groupId"];
- [parm setValue:page forKey:@"page"];
- [parm setValue:rows forKey:@"rows"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- #pragma mark ----- 直播相关
- // 进入直播房间
- // /api-student/liveRoom/joinRoom
- /// 进入房间
- /// @param get get
- /// @param roomUid 直播房间号
- /// @param success 成功
- /// @param faliure 失败
- + (void)liveRoomJoinRoomRequest:(NSString *)get roomUid:(NSString *)roomUid success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- NSString *url = [NSString stringWithFormat:@"%@%@", hostURL, @"/api-student/liveRoom/joinRoom"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:roomUid forKey:@"roomUid"];
- [parm setValue:UserDefault(UIDKey) forKey:@"userId"];
- [self request:get andWithUrl:url and:parm success:success faliure:faliure];
- }
- // 退出直播间通知
- // /api-student/liveRoom/syncUserStatus
- /// 退出直播间
- /// @param post post json
- /// @param success 成功
- /// @param faliure 失败
- + (void)LiveroomQuit:(NSString *)post success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@", SEALCLASSHOST, @"/api-student/liveRoom/syncUserStatus"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:@"iOS" forKey:@"os"];
- [parm setValue:@"3" forKey:@"status"];
- [parm setValue:UserDefault(UIDKey) forKey:@"userid"];
- [self request:post andWithUrl:url and:@[parm] success:success faliure:faliure];
- }
- #pragma mark ----- 课表
- // /api-student/courseSchedule/queryCourseScheduleStudent
- /// 课表日历
- /// @param post post
- /// @param classMonth 月份
- /// @param success 成功
- /// @param faliure 失败
- + (void)queryCourseSchedule:(NSString *)post classMonth:(NSString *)classMonth success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@", hostURL, @"/api-student/courseSchedule/queryCourseScheduleStudent"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:classMonth forKey:@"classMonth"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- // /api-student/courseSchedule/queryCourseUser
- /// 查询日期课程
- /// @param post post
- /// @param classDate 日期
- /// @param success 成功
- /// @param faliure 失败
- + (void)queryCourseForDay:(NSString *)post classDate:(NSString *)classDate success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
- [self configRequestMethodJSON];
- NSString *url = [NSString stringWithFormat:@"%@%@", hostURL, @"/api-student/courseSchedule/queryCourseUser"];
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:classDate forKey:@"classDate"];
- [self request:post andWithUrl:url and:parm success:success faliure:faliure];
- }
- @end
|