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.
98 lines
3.1 KiB
98 lines
3.1 KiB
// |
|
// HeartAndTempModel.m |
|
// tongxin |
|
// |
|
// Created by Apple on 2020/4/9. |
|
// Copyright © 2020 xTT. All rights reserved. |
|
// |
|
|
|
#import "HeartAndTempModel.h" |
|
#import "User.h" |
|
#import "Device.h" |
|
|
|
@implementation HeartAndTempModel |
|
|
|
/// 根据日期获取数据接口 |
|
/// @param type 0:心率, 1:体温 |
|
/// @param dateTime 日期 格式: 2020-03-25 |
|
+ (void)getHeartAndTempDataWithType:(int)type |
|
date:(NSString*)dateTime |
|
success:(void (^)(HeartAndTempModel *model))success |
|
failure:(void (^)(NSError *error))failure{ |
|
|
|
NSString *urlStr = [MyHttp getURL:HTTP_DEVICES_HeartAndTemp |
|
objArr:@[cUser.cDevice]]; |
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
NSString *cmd = @"temperature"; |
|
if (type == 0) { |
|
cmd = @"heart"; |
|
} |
|
[parameters setValue:cmd forKey:@"cmd"]; |
|
[parameters setValue:dateTime forKey:@"date"]; |
|
[xMyHttp URL:urlStr |
|
method:@"GET" parameters:parameters |
|
success:^(NSURLSessionDataTask *task, id responseObject) |
|
{ |
|
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) { |
|
HeartAndTempModel *model = [HeartAndTempModel mj_objectWithKeyValues:responseObject]; |
|
if([responseObject valueForKey:@"switch"]){ |
|
model.switchStatus = @([[responseObject valueForKey:@"switch"] boolValue]); |
|
} |
|
success(model); |
|
}else{ |
|
if (failure) { |
|
failure(nil); |
|
} |
|
} |
|
} failure:^(NSURLSessionDataTask *task, NSError *error) { |
|
if (failure) { |
|
failure(error); |
|
} |
|
}]; |
|
|
|
|
|
} |
|
|
|
|
|
/// 设置 心率/体温 数据的接口 |
|
/// @param type 0:心率, 1:体温 |
|
/// @param params 参数 switch* : [int] 功能的开关 0: 关闭 ,1: 打开 frequency* : [str] 频率 /分钟 | 当-1时为立刻查询一次 |
|
+ (void)postHeartAndTempDataWithType:(int)type |
|
params:(NSArray*)params |
|
success:(void (^)(id responseObject))success |
|
failure:(void (^)(NSError *error))failure{ |
|
NSString *urlStr = [MyHttp getURL:HTTP_DEVICES_HeartAndTemp |
|
objArr:@[cUser.cDevice]]; |
|
|
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
NSString *cmd = @"setTemperature"; |
|
if (type == 0) { |
|
cmd = @"setHeart"; |
|
} |
|
[parameters setValue:cmd forKey:@"cmd"]; |
|
for (NSDictionary *item in params) { |
|
[parameters addEntriesFromDictionary:item]; |
|
} |
|
|
|
[xMyHttp URL:urlStr |
|
method:@"POST" parameters:parameters |
|
success:^(NSURLSessionDataTask *task, id responseObject) |
|
{ |
|
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) { |
|
success(responseObject); |
|
}else{ |
|
if (failure) { |
|
failure(nil); |
|
} |
|
} |
|
} failure:^(NSURLSessionDataTask *task, NSError *error) { |
|
if (failure) { |
|
failure(error); |
|
} |
|
}]; |
|
|
|
|
|
|
|
} |
|
@end
|
|
|