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.

93 lines
2.4 KiB

//
// Rail.m
// myWear
//
// Created by xTT on 2017/2/21.
// Copyright © 2017xTT. All rights reserved.
//
#import "Rail.h"
#import "User.h"
@implementation Rail
@synthesize status = _status;
-(NSString *)week{
if (!_week) {
_week = @"1111100";
}
return _week;
}
+ (void)getObjsSuccess:(void (^)(NSMutableArray *arr))success
failure:(void (^)(NSError *error))failure{
NSString *urlStr = [MyHttp getURL:@"getway/devices/[imei]/rail"
objArr:@[cUser.cDevice]];
[xMyHttp URL:urlStr
method:@"GET" parameters:@{}
success:^(NSURLSessionDataTask *task, id responseObject)
{
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) {
NSMutableArray *arr = [Rail mj_objectArrayWithKeyValuesArray:responseObject[@"rails"]];
success(arr);
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)saveSuccess:(void (^)())success
failure:(void (^)())failure{
NSString *urlStr = [MyHttp getURL:@"getway/devices/[imei]/rail"
objArr:@[cUser.cDevice]];
NSString *method = @"POST";
if (self.id.length > 0) {
method = @"PATCH";
}
[xMyHttp URL:urlStr
method:method parameters:[self mj_keyValues]
success:^(NSURLSessionDataTask *task, id responseObject)
{
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) {
success();
}else{
failure();
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (failure) {
failure();
}
}];
}
- (void)deleteSuccess:(void (^)())success
failure:(void (^)())failure{
NSString *urlStr = [MyHttp getURL:@"getway/devices/[imei]/rail"
objArr:@[cUser.cDevice]];
[xMyHttp URL:urlStr
method:@"DELETE" parameters:@{@"id":self.id}
success:^(NSURLSessionDataTask *task, id responseObject)
{
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) {
success();
}else{
failure();
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (failure) {
failure();
}
}];
}
- (void)setDefaultValue{
_week = @"1111100";
_starttime = @"08:00";
_endedtime = @"17:00";
}
@end