//
//  DialogueCountentHttpGetCmd+Response.m
//  MobilePortal
//
//  Created by caiyang on 2020/4/11.
//  Copyright © 2020 yin chen. All rights reserved.
//

#import "DialogueCountentHttpGetCmd+Response.h"
#import "DialogueCountentHttpGetCmd.h"
#import "DialogueCountentHttpGetResult.h"


@protocol DialogueCountentHttpGetResultData;
@interface DialogueCountentHttpGetResultData : JSONModel
@property NSString<Optional>*id;
@property NSString<Optional>*folderid;
@property NSString<Optional>*title;
@property NSString<Optional>*status;
@property NSString<Optional>*createon;
@property NSString<Optional>*createby;
@property NSString<Optional>*orderType;
@property NSString<Optional>*createbyname;
@property NSString<Optional>*docname;
@property NSString<Optional>*type;
@property NSString<Optional>*foldertype;
@property NSString<Optional>*content;
@end
@implementation DialogueCountentHttpGetResultData
@synthesize description;
@end


@interface DialogueCountentHttpGetResult()
@property DialogueCountentHttpGetResultData *data;
@end

@implementation DialogueCountentHttpGetCmd (Response)

- (void)onRequestSuccess:(id)request code:(NSInteger)code{
    
    [self.result setResultState:kRequestResultSuccess];
    NSDictionary *dic = (NSDictionary *)request;
    DialogueCountentHttpGetResult *result = [[DialogueCountentHttpGetResult alloc]init];
    result = (DialogueCountentHttpGetResult *)self.result;
    if (code>199&&code<299) {
        [self.result setResultState:kRequestResultSuccess];
        NSError *error;
        result.data = [[DialogueCountentHttpGetResultData 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 DialogueCountentHttpGetResult
- (NSMutableArray *)getDialogueCountentHttpGetResult{
    NSMutableArray *httpArray = [NSMutableArray array];
    DialogueCountentModel *model = [[DialogueCountentModel alloc]init];
    model.id = [self getNilString:self.data.id];
    //    model.content = @"";
    model.content = [self getNilString:self.data.content];
//    [model.content stringByReplacingOccurrencesOfString:@"14" withString:@"13"];
    model.folderid = [self getNilString:self.data.folderid];
    model.title = [self getNilString:self.data.title];
    model.status = [self getNilString:self.data.status];
    model.createon = [self getNilString:self.data.createon];
    model.createby = [self getNilString:self.data.createby];
    model.createbyname = [self getNilString:self.data.createbyname];
    model.docname = [self getNilString:self.data.docname];
    model.type = [self getNilString:self.data.type];
    model.foldertype = [self getNilString:self.data.foldertype];
    [httpArray addObject:model];
    return httpArray;
}
@end
