//
//  UpcomingSystemHttpPostCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2020/5/6.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "UpcomingSystemHttpPostCmd+Response.h"
#import "UpcomingSystemHttpPostCmd.h"
#import "UpcomingSystemHttpResult.h"


@protocol UpcomingSystemHttpResultDataContent;
@interface UpcomingSystemHttpResultDataContent : JSONModel
@property NSString<Optional>*applicationid;
@property NSString<Optional>*createby;
@property NSString<Optional>*updateby;
@property NSString<Optional>*status;
@property NSString<Optional>*iconurl;
@property NSString<Optional>*partstate;
@property NSString<Optional>*belong;
@property NSString<Optional>*hurl;
@property NSString<Optional>*iosurl;
@property NSString<Optional>*name;
@property NSString<Optional>*hversion;
@property NSString<Optional>*createon;
@property NSString<Optional>*updateon;
@property NSString<Optional>*companystate;
@property NSString<Optional>*androidurl;
@property NSString<Optional>*scope;
@property NSString<Optional>*androidversion;
@property NSString<Optional>*pointstate;
@property NSString<Optional>*platforms;
@property NSString<Optional>*empuidstate;
@property NSString<Optional>*passstate;
@property NSString<Optional>*iosversion;
@property NSString<Optional>*introduce;
@property NSString<Optional>*htitle;
@property NSString<Optional>*androidname;
@property NSString<Optional>*androidcontent;
@property NSString<Optional>*iosbundieid;
@property NSString<Optional>*iosopenurl;
@property NSString<Optional>*ioscontent;
@property NSString<Optional>*hcontent;


@property NSString<Optional>*value1;
@property NSString<Optional>*value2;
@property NSString<Optional>*value3;
@property NSString<Optional>*value4;
@property NSString<Optional>*value5;
@property NSString<Optional>*appid;
@end
@implementation UpcomingSystemHttpResultDataContent
@synthesize description;
@end

@protocol UpcomingSystemHttpResultDataData;
@interface UpcomingSystemHttpResultDataData : JSONModel
@property NSString<Optional>*name;
@property NSString<Optional>*count;
@property UpcomingSystemHttpResultDataContent *content;
@end
@implementation UpcomingSystemHttpResultDataData
@synthesize description;
@end

@protocol UpcomingSystemHttpResultData;
@interface UpcomingSystemHttpResultData : JSONModel
@property NSMutableArray<Optional,UpcomingSystemHttpResultDataData> *data;
@property NSString<Optional>*msg;
@property NSString<Optional>*code;
@end
@implementation UpcomingSystemHttpResultData
@synthesize description;
@end

@interface UpcomingSystemHttpResult()
@property UpcomingSystemHttpResultData *data;
@end


@implementation UpcomingSystemHttpPostCmd (Response)
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    UpcomingSystemHttpResult *result = [[UpcomingSystemHttpResult alloc]init];
    result = (UpcomingSystemHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[UpcomingSystemHttpResultData alloc]initWithDictionary:dic error:(NSError **)&error];
        if(error){
            [self onRequestFailed:error];
            return;
        }
    }else{
        NSString *memo = [dic objectForKey:@"error_description"];
        [self.result setResultState:kRequestResultFail];
        [self.result setErrMsg:memo];
        NSLog(@"code :%ld errormsg:%@",(long)code,memo);
    }
}
- (void)onRequestFailed:(NSError *)error{
    NSLog(@"Error===%@",error);
    [self.result setErrMsg:[error localizedDescription]];
    [self.result setResultState:kRequestResultFail];
}
@end
@implementation UpcomingSystemHttpResult
- (NSMutableArray *)getUpcomingSystemHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    for (int index = 0 ; index < self.data.data.count; index ++) {
        UpcomingSystemModel *model = [[UpcomingSystemModel alloc]init];
        UpcomingSystemHttpResultDataData *httpModel = self.data.data[index];
        model.name = [self getNilString:httpModel.name];
        model.count = [self getNilString:httpModel.count];
        model.content.applicationid = [self getNilString:httpModel.content.applicationid];
        model.content.createby = [self getNilString:httpModel.content.createby];
        model.content.updateby = [self getNilString:httpModel.content.updateby];
        model.content.status = [self getNilString:httpModel.content.status];
        model.content.iconurl = [self getNilString:httpModel.content.iconurl];
        model.content.imageUrl = [self getImageUrl:model.content.iconurl];
        model.content.partstate = [self getNilString:httpModel.content.partstate];
        model.content.belong = [self getNilString:httpModel.content.belong];
        model.content.hurl = [self getNilString:httpModel.content.hurl];
        model.content.iosurl = [self getNilString:httpModel.content.iosurl];
        model.content.name = [self getNilString:httpModel.content.name];
        model.content.hversion = [self getNilString:httpModel.content.hversion];
        model.content.createon = [self getNilString:httpModel.content.createon];
        model.content.updateon = [self getNilString:httpModel.content.updateon];
        model.content.companystate = [self getNilString:httpModel.content.companystate];
        model.content.androidurl = [self getNilString:httpModel.content.androidurl];
        model.content.scope = [self getNilString:httpModel.content.scope];
        model.content.androidversion = [self getNilString:httpModel.content.androidversion];
        model.content.pointstate = [self getNilString:httpModel.content.pointstate];
        model.content.platforms = [self getNilString:httpModel.content.platforms];
        model.content.empuidstate = [self getNilString:httpModel.content.empuidstate];
        model.content.passstate = [self getNilString:httpModel.content.passstate];
        model.content.iosversion = [self getNilString:httpModel.content.iosversion];
        model.content.introduce = [self getNilString:httpModel.content.introduce];
        model.content.ioscontent = [self getNilString:httpModel.content.ioscontent];
        model.content.iosbundieid = [self getNilString:httpModel.content.iosbundieid];
        model.content.iosopenurl = [self getNilString:httpModel.content.iosopenurl];
        if ([model.content.iosopenurl rangeOfString:@"://"].location == NSNotFound && ![model.content.iosopenurl isEqualToString:@""]) {
            model.content.iosopenurl = [NSString stringWithFormat:@"%@://",model.content.iosopenurl];
        }
        model.content.androidname = [self getNilString:httpModel.content.androidname];
        model.content.androidcontent = [self getNilString:httpModel.content.androidcontent];
        model.content.hcontent = [self getNilString:httpModel.content.hcontent];
        model.content.htitle = [self getNilString:httpModel.content.htitle];
        model.content.value1 = [self getNilString:httpModel.content.value1];
        model.content.value2 = [self getNilString:httpModel.content.value2];
        model.content.value3 = [self getNilString:httpModel.content.value3];
        model.content.value4 = [self getNilString:httpModel.content.value4];
        model.content.value5 = [self getNilString:httpModel.content.value5];
        model.content.appid = [self getNilString:httpModel.content.appid];
        
        [httpArray addObject:model];
    }
    return httpArray;
}
@end
