You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.8 KiB
59 lines
1.8 KiB
// |
|
// TimingSwitchModel.m |
|
// tongxin |
|
// |
|
// Created by Apple on 2020/4/10. |
|
// Copyright © 2020 xTT. All rights reserved. |
|
// |
|
|
|
#import "TimingSwitchModel.h" |
|
#import "User.h" |
|
#import "Device.h" |
|
|
|
@implementation TimingSwitchModel |
|
|
|
|
|
+ (void)getTimingSwitchDataSuccess:(void (^)(TimingSwitchModel *model))success |
|
failure:(void (^)(NSError *error))failure{ |
|
|
|
NSString *urlStr = [MyHttp getURL:HTTP_DEVICES_TimingSwitch objArr:@[cUser.cDevice]]; |
|
[xMyHttp URL:urlStr |
|
method:@"GET" parameters:nil |
|
success:^(NSURLSessionDataTask *task, id responseObject) |
|
{ |
|
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) { |
|
TimingSwitchModel *model = [TimingSwitchModel mj_objectWithKeyValues:responseObject]; |
|
model.switchStatus = responseObject[@"switch"]; |
|
success(model); |
|
} |
|
} failure:^(NSURLSessionDataTask *task, NSError *error) { |
|
if (failure) { |
|
failure(error); |
|
} |
|
}]; |
|
|
|
} |
|
|
|
- (void)postTimingSwitchDataSuccess:(void (^)(id responseObject))success |
|
failure:(void (^)(NSError *error))failure{ |
|
NSMutableDictionary *param = self.mj_keyValues; |
|
xLog(@"定时开关机 POST 提交的参数: %@", param); |
|
[param setValue:self.switchStatus forKey:@"switch"]; |
|
[param removeObjectForKey:@"switchStatus"]; |
|
|
|
NSString *urlStr = [MyHttp getURL:HTTP_DEVICES_TimingSwitch objArr:@[cUser.cDevice]]; |
|
[xMyHttp URL:urlStr |
|
method:@"POST" parameters:param |
|
success:^(NSURLSessionDataTask *task, id responseObject) |
|
{ |
|
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) { |
|
success(responseObject); |
|
} |
|
} failure:^(NSURLSessionDataTask *task, NSError *error) { |
|
if (failure) { |
|
failure(error); |
|
} |
|
}]; |
|
} |
|
|
|
@end
|
|
|