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.
 
 
 
 

96 lines
2.5 KiB

//
// DisturbBan.m
// myWear
//
// Created by xTT on 2017/3/4.
// Copyright © 2017年 xTT. All rights reserved.
//
#import "DisturbBan.h"
#import "User.h"
@implementation DisturbBan
@synthesize status = _status;
+ (void)getObjsSuccess:(void (^)(NSMutableArray *arr))success
failure:(void (^)(NSError *error))failure{
NSString *urlStr = [MyHttp getURL:@"[vendor]/devices/[imei]/disturbBan"
objArr:@[cUser.cDevice]];
[xMyHttp URL:urlStr
method:@"GET" parameters:@{}
success:^(NSURLSessionDataTask *task, id responseObject)
{
if ([responseObject[@"code"] intValue] == HTTP_SUCCESS) {
NSMutableArray *arr = [DisturbBan mj_objectArrayWithKeyValuesArray:responseObject[@"disturbBans"]];
success(arr);
}
} failure:^(NSURLSessionDataTask *task, NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)saveSuccess:(void (^)())success
failure:(void (^)())failure{
NSString *urlStr = [MyHttp getURL:@"[vendor]/devices/[imei]/disturbBan"
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:@"[vendor]/devices/[imei]/disturbBan"
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";
}
- (NSNumber *)status{
if (!_status) {
return @(YES);
}
return _status;
}
@end