//
//  MoreApplicationsTwoHttpCmd+Response.m
//  MobilePortal
//
//  Created by xiejiangbo on 2019/9/26.
//  Copyright © 2019 yin chen. All rights reserved.
//

#import "MoreApplicationsTwoHttpCmd+Response.h"
#import "MoreApplicationsTwoHttpResult.h"


@protocol MoreApplicationsTwoHttpResultDataList;
@interface MoreApplicationsTwoHttpResultDataList : JSONModel
@property NSString<Optional>*docname;
@property NSString<Optional>*status;
@property NSString<Optional>*title;
@property NSString<Optional>*createby;
@property NSString<Optional>*updateby;
@property NSString<Optional>*tags;
@property NSString<Optional>*image;
@property NSString<Optional>*listimage;
@property NSString<Optional>*sort;
@property NSString<Optional>*kgimage;
@property NSString<Optional>*homeshow;
@property NSString<Optional>*createon;
@property NSString<Optional>*updateon;
@property NSString<Optional>*type;
@property NSString<Optional>*id;
@property NSString<Optional>*createbyname;
@property NSString<Optional>*foldertype;
@property NSString<Optional>*updatebyname;
@property NSString<Optional>*comments;
@property NSString<Optional>*pid;
@property NSString<Optional>*author;
@property NSString<Optional>*openurl;
@property NSString<Optional>*appid;
@property NSString<Optional>*scopes;
@end
@implementation MoreApplicationsTwoHttpResultDataList
@synthesize description;
@end


@protocol MoreApplicationsTwoHttpResultData;
@interface MoreApplicationsTwoHttpResultData : JSONModel
    
@property NSString<Optional>*pageNum;
@property NSString<Optional>*pages;
@property NSString<Optional>*pageSize;
@property NSString<Optional>*size;
@property NSString<Optional>*status;
@property NSMutableArray<Optional,MoreApplicationsTwoHttpResultDataList> *list;
@end
@implementation MoreApplicationsTwoHttpResultData
@synthesize description;
@end


@interface MoreApplicationsTwoHttpResult()
@property MoreApplicationsTwoHttpResultData *data;
@end

@implementation MoreApplicationsTwoHttpCmd (Response)
    
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    MoreApplicationsTwoHttpResult *result = [[MoreApplicationsTwoHttpResult alloc]init];
    result = (MoreApplicationsTwoHttpResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[MoreApplicationsTwoHttpResultData 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 MoreApplicationsTwoHttpResult
- (NSMutableArray *)getMoreApplicationsTwoHttpResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    for (int index = 0; index < self.data.list.count; index ++) {
//        AdvisoryHttpListModel *model = [[AdvisoryHttpListModel alloc]init];
        ApplicationHttpListModel *model = [[ApplicationHttpListModel alloc]init];
        MoreApplicationsTwoHttpResultDataList *httpModel = self.data.list[index];
        model.docname = [self getNilString:httpModel.docname];
        model.status = [self getNilString:httpModel.status];
        model.title = [self getNilString:httpModel.title];
        model.createby = [self getNilString:httpModel.createby];
        model.updateby = [self getNilString:httpModel.updateby];
        model.tags = [self getNilString:httpModel.tags];
        model.image = [self getNilString:httpModel.image];
        model.imageUrl = [self getImageUrl:model.image];
        model.listimage = [self getNilString:httpModel.listimage];
        model.sort = [self getNilString:httpModel.sort];
        model.scopes = [self getNilString:httpModel.scopes];
        model.kgimage = [self getNilString:httpModel.kgimage];
        model.homeshow = [self getNilString:httpModel.homeshow];
        model.createon = [self getNilString:httpModel.createon];
        model.updateon = [self getNilString:httpModel.updateon];
        model.type = [self getNilString:httpModel.type];
        model.id = [self getNilString:httpModel.id];
        model.createbyname = [self getNilString:httpModel.createbyname];
        model.foldertype = [self getNilString:httpModel.foldertype];
        model.updatebyname = [self getNilString:httpModel.updatebyname];
        model.comments = [self getNilString:httpModel.comments];
        model.pid = [self getNilString:httpModel.pid];
        model.author = [self getNilString:httpModel.author];
        model.appid = [self getNilString:httpModel.appid];
        model.openurl = [self getNilString:httpModel.openurl];
        model.iosopenurl = [self getNilString:httpModel.openurl];
        model.name = [self getNilString:httpModel.title];
        model.belong = [self getNilString:httpModel.tags];
        model.applicationid = [self getNilString:httpModel.title];
        [httpArray addObject:model];
    }
    return httpArray;
}
    @end

