//
//  UserInfoHttpPostCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2020/8/13.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "UserInfoHttpPostCmd+Response.h"
#import "UserInfoHttpPostCmd.h"
#import "UserInfoHttpPostResult.h"


@protocol UserInfoHttpPostResultItemData;
@interface UserInfoHttpPostResultItemData : 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;
@end
@implementation UserInfoHttpPostResultItemData
@synthesize description;
@end


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


@interface UserInfoHttpPostResult()
@property UserInfoHttpPostResultData *data;
@end


@implementation UserInfoHttpPostCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    UserInfoHttpPostResult *result = [[UserInfoHttpPostResult alloc]init];
    result = (UserInfoHttpPostResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[UserInfoHttpPostResultData 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 UserInfoHttpPostResult
- (NSMutableArray *)getUserInfoHttpPostResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    if (!self.data.data) {
        [httpArray addObject:[[MyInformationHttpModel alloc]init]];
        return httpArray;
    }
    for (int index = 0; index < self.data.data.count; index ++) {
        UserInfoHttpPostResultItemData *item = self.data.data[index];
        MyInformationHttpModel *inforModel = [[MyInformationHttpModel alloc]init];
        inforModel.homefax = [self getNilString:item.homefax];
        inforModel.deptid = [self getNilString:item.deptid];
        inforModel.defaultposid = [self getNilString:item.defaultposid];
        inforModel.empuid = [self getNilString:item.empuid];
        inforModel.remark = [self getNilString:item.remark];
        inforModel.companyname = [self getNilString:item.companyname];
        inforModel.displayname = [self getNilString:item.displayname];
        inforModel.id = [self getNilString:item.id];
        inforModel.state = [self getNilString:item.state];
        inforModel.phone2 = [self getNilString:item.phone2];
        inforModel.empid = [self getNilString:item.empid];
        inforModel.wechat = [self getNilString:item.wechat];
        inforModel.type = [self getNilString:item.type];
        inforModel.mystyle = [self getNilString:item.mystyle];
        inforModel.sex = [self getNilString:item.sex];
        inforModel.email = [self getNilString:item.email];
        inforModel.useralias = [self getNilString:item.useralias];
        inforModel.birthday = [self getNilString:item.birthday];
        inforModel.mobilephone = [self getNilString:item.mobilephone];
        inforModel.fullroute = [self getNilString:item.fullroute];
        inforModel.defaultposname = [self getNilString:item.defaultposname];
        inforModel.headportraitid = [self getNilString:item.headportraitid];
        inforModel.status = [self getNilString:item.status];
        inforModel.cnname = [self getNilString:item.cnname];
        inforModel.headportraiturl = [self getNilString:item.headportraiturl];
        inforModel.homeaddress = [self getNilString:item.homeaddress];
        inforModel.qq = [self getNilString:item.qq];
        inforModel.deptnames = [self getNilString:item.deptnames];
        inforModel.deptids = [self getNilString:item.deptids];
        inforModel.deptname = [self getNilString:item.deptname];
        inforModel.companyid = [self getNilString:item.companyid];
        inforModel.superior = [self getNilString:item.superior];
        inforModel.phone = [self getNilString:item.phone];
        inforModel.lockstatus = [self getNilString:item.lockstatus];
        inforModel.password = [self getNilString:item.password];
        inforModel.enname = [self getNilString:item.enname];
        inforModel.enname = [self getNilString:item.enname];
        inforModel.wechatname = [self getNilString:item.wechatname];
        [httpArray addObject:inforModel];
    }
    return httpArray;
}
@end
