//
//  MyInformationHttpGetCmd+Response.m
//  MobilePortal
//
//  Created by xiejiangbo on 2019/3/15.
//  Copyright © 2019 yin chen. All rights reserved.
//

#import "MyInformationHttpGetCmd+Response.h"
#import "MyInformationHttpGetResult.h"


@protocol MyInformationHttpGetResultDataOrg;
@interface MyInformationHttpGetResultDataOrg : JSONModel
@property NSString<Optional>*id;
@property NSString<Optional>*deptid;
@property NSString<Optional>*createby;
@property NSString<Optional>*deptname;
@property NSString<Optional>*createon;
@property NSString<Optional>*updateby;
@property NSString<Optional>*optno;
@property NSString<Optional>*cnname;
@property NSString<Optional>*updateon;
@property NSString<Optional>*empid;
@property NSString<Optional>*companyname;
@property NSString<Optional>*companyid;

@end
@implementation MyInformationHttpGetResultDataOrg
@synthesize description;
@end



@protocol MyInformationHttpGetResultData;
@interface MyInformationHttpGetResultData : JSONModel
@property NSString<Optional>*homefax;
@property NSString<Optional>*deptid;
@property NSString<Optional>*empuid;
@property NSString<Optional>*remark;
@property NSString<Optional>*companyname;
@property NSString<Optional>*displayname;
@property NSString<Optional>*id;
@property NSString<Optional>*state;

@property NSString<Optional>*phone2;
@property NSString<Optional>*empid;
@property NSString<Optional>*wechat;
@property NSString<Optional>*type;
@property NSString<Optional>*mystyle;
@property NSString<Optional>*sex;
@property NSString<Optional>*email;
@property NSString<Optional>*useralias;
@property NSString<Optional>*birthday;
@property NSString<Optional>*mobilephone;
@property NSString<Optional>*fullroute;
@property NSString<Optional>*defaultposname;
@property NSString<Optional>*headportraitid;
@property NSString<Optional>*status;
@property NSString<Optional>*cnname;
@property NSString<Optional>*headportraiturl;
@property NSString<Optional>*homeaddress;
@property NSString<Optional>*qq;
@property NSString<Optional>*deptnames;
@property NSString<Optional>*deptids;
@property NSString<Optional>*deptname;
@property NSString<Optional>*companyid;
@property NSString<Optional>*superior;
@property NSString<Optional>*phone;
@property NSString<Optional>*lockstatus;
@property NSString<Optional>*password;
@property NSString<Optional>*enname;
@property NSString<Optional>*defaultposid;
@property NSString<Optional>*is_deleted;
@property NSString<Optional>*wechatname;

@property NSMutableArray<Optional,MyInformationHttpGetResultDataOrg> *org;
@end
@implementation MyInformationHttpGetResultData
@synthesize description;
@end


@interface MyInformationHttpGetResult()
@property MyInformationHttpGetResultData *data;
@end
@implementation MyInformationHttpGetCmd (Response)
- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    MyInformationHttpGetResult *result = [[MyInformationHttpGetResult alloc]init];
    result = (MyInformationHttpGetResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[MyInformationHttpGetResultData 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 MyInformationHttpGetResult

- (NSMutableArray *)getMyInformationAllData{
    NSMutableArray *httpArray = [NSMutableArray array];
    MyInformationHttpModel *inforModel = [[MyInformationHttpModel alloc]init];
    inforModel.homefax = [self getNilString:self.data.homefax];
    inforModel.deptid = [self getNilString:self.data.deptid];
    inforModel.defaultposid = [self getNilString:self.data.defaultposid];
    inforModel.empuid = [self getNilString:self.data.empuid];
    inforModel.remark = [self getNilString:self.data.remark];
    inforModel.companyname = [self getNilString:self.data.companyname];
    inforModel.displayname = [self getNilString:self.data.displayname];
    inforModel.id = [self getNilString:self.data.id];
    inforModel.state = [self getNilString:self.data.state];
    inforModel.phone2 = [self getNilString:self.data.phone2];
    inforModel.empid = [self getNilString:self.data.empid];
    inforModel.wechat = [self getNilString:self.data.wechat];
    inforModel.type = [self getNilString:self.data.type];
    inforModel.mystyle = [self getNilString:self.data.mystyle];
    inforModel.sex = [self getNilString:self.data.sex];
    inforModel.email = [self getNilString:self.data.email];
    inforModel.useralias = [self getNilString:self.data.useralias];
    inforModel.birthday = [self getNilString:self.data.birthday];
    inforModel.mobilephone = [self getNilString:self.data.mobilephone];
    inforModel.fullroute = [self getNilString:self.data.fullroute];
    inforModel.defaultposname = [self getNilString:self.data.defaultposname];
    inforModel.headportraitid = [self getNilString:self.data.headportraitid];
    inforModel.status = [self getNilString:self.data.status];
    inforModel.cnname = [self getNilString:self.data.cnname];
    inforModel.headportraiturl = [self getNilString:self.data.headportraiturl];
    inforModel.homeaddress = [self getNilString:self.data.homeaddress];
    inforModel.qq = [self getNilString:self.data.qq];
    inforModel.deptnames = [self getNilString:self.data.deptnames];
    inforModel.deptids = [self getNilString:self.data.deptids];
    inforModel.deptname = [self getNilString:self.data.deptname];
    inforModel.companyid = [self getNilString:self.data.companyid];
    inforModel.superior = [self getNilString:self.data.superior];
    inforModel.phone = [self getNilString:self.data.phone];
    inforModel.lockstatus = [self getNilString:self.data.lockstatus];
    inforModel.password = [self getNilString:self.data.password];
    inforModel.enname = [self getNilString:self.data.enname];
    inforModel.enname = [self getNilString:self.data.enname];
    inforModel.wechatname = [self getNilString:self.data.wechatname];
    for (int index = 0; index<self.data.org.count; index++) {
        MyInformationHttpModelOrg *orgModel = [[MyInformationHttpModelOrg alloc]init];
        MyInformationHttpGetResultDataOrg *httpOrgModel = self.data.org[index];
        orgModel.id = [self getNilString:httpOrgModel.id];
        orgModel.deptid = [self getNilString:httpOrgModel.deptid];
        orgModel.createby = [self getNilString:httpOrgModel.createby];
        orgModel.deptname = [self getNilString:httpOrgModel.deptname];
        orgModel.createon = [self getNilString:httpOrgModel.createon];
        orgModel.updateby = [self getNilString:httpOrgModel.updateby];
        orgModel.optno = [self getNilString:httpOrgModel.optno];
        orgModel.cnname = [self getNilString:httpOrgModel.cnname];
        orgModel.updateon = [self getNilString:httpOrgModel.updateon];
        orgModel.empid = [self getNilString:httpOrgModel.empid];
        orgModel.companyname = [self getNilString:httpOrgModel.companyname];
        orgModel.companyid = [self getNilString:httpOrgModel.companyid];
        [inforModel.org addObject:orgModel];
    }
    [httpArray addObject:inforModel];
    return httpArray;
}
@end
