IOS搭建基础开发框架(6)网络层AFNetworking

AFNetworking大家都不陌生,本文对其进行了最简单的封装,功能实现:GET、POST、单文件上传、多文件上传、文件下载。

AFNetworking实现GET、POST、上传、下载功能简单封装

先用java Spring Boot模拟实现后台接口

对后台不懂的同学可以略过,模拟使用的Spring Boot实现的RestFul接口。直接上码

package com.moxi.controller;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import javax.servlet.http.HttpSession;

import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.moxi.model.ResObject;
import com.moxi.model.User;
import com.moxi.util.Constant;

@RestController
public class AppController {
    
    /*
     * GET请求
     */
    @GetMapping("/app/login")
    public ResObject<Object> login(User user) {
        System.out.println("UserName :" + user.getUserName());
        System.out.println("Password" + user.getPassword());
        ResObject<Object> object = new ResObject<Object>(Constant.Code01, Constant.Msg01, user, null);
        return object;
    }
    
    /*
     * POST请求
     */
    @PostMapping("/app/register")
    public ResObject<Object> register(User user) {
        System.out.println("UserName :" + user.getUserName());
        System.out.println("Password" + user.getPassword());
        ResObject<Object> object = new ResObject<Object>(Constant.Code01, Constant.Msg01, user, null);
        return object;
    }
    
    /*
     * 单文件上传
     */
    @PostMapping("/app/upload")
    public ResObject<Object> upload(User user,@RequestParam MultipartFile imageFile,HttpSession httpSession) {
        System.out.println("UserName :" + user.getUserName());
        System.out.println("Password" + user.getPassword());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = new java.util.Date();
        String strDate = sdf.format(date);
        String fileName = strDate + imageFile.getOriginalFilename().substring(imageFile.getOriginalFilename().indexOf("."),imageFile.getOriginalFilename().length());
        String realPath = httpSession.getServletContext().getRealPath("/userfiles");
        System.out.println("realPath : "+realPath);
        try {
            FileUtils.copyInputStreamToFile(imageFile.getInputStream(),new File(realPath, fileName));
        } catch (IOException e) {
            e.printStackTrace();
        }
        ResObject<Object> object = new ResObject<Object>(Constant.Code01, Constant.Msg01, user, null);
        return object;
    }
    
    /*
     * 多文件上传
     */
    @PostMapping("/app/uploads")
    public ResObject<Object> uploads(User user, @RequestParam MultipartFile[] imageFile,HttpSession httpSession) {
        System.out.println("UserName :" + user.getUserName());
        System.out.println("Password" + user.getPassword());
        for (MultipartFile file : imageFile) {
            if (file.isEmpty()) {
                System.out.println("文件未上传");
            } else {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
                Random random = new Random();
                Date date = new java.util.Date();
                String strDate = sdf.format(date);
                String fileName = strDate  + random.nextInt(1000) + file.getOriginalFilename().substring(file.getOriginalFilename().indexOf("."),file.getOriginalFilename().length());
                String realPath = httpSession.getServletContext().getRealPath("/userfiles");
                System.out.println("realPath : "+realPath);
                System.out.println("fileName : "+fileName);
                try {
                    FileUtils.copyInputStreamToFile(file.getInputStream(),new File(realPath, fileName));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        ResObject<Object> object = new ResObject<Object>(Constant.Code01, Constant.Msg01, user, null);
        return object;
    }

}

GET请求的结果如图,返回的是JSON格式数据


GET请求的结果

AFNetworking简单封装

定义SSNetworkingManager继承自AFHTTPSessionManager,并实现单利方法,此处希望有看过AF源码的同学给出建议,是用单利比较合适还是每个请求都初始化一个AFHTTPSessionManager

SSNetworkingManager.h

//
//  SSNetworkingManager.h
//  SZSSV1
//
//  Created by DaLei on 2017/6/10.
//  Copyright © 2017年 DaLei. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>
#import "SSConfig.h"

@class SSImageModel;

typedef void (^ _Nullable Success)(id _Nullable responseObject);// 成功Block
typedef void (^ _Nullable Failure)(NSError * _Nullable error);// 失败Blcok
typedef void (^ _Nullable Progress)(NSProgress * _Nullable progress);// 上传或者下载进度Block
typedef NSURL * _Nullable (^ _Nullable Destination)(NSURL * _Nullable targetPath, NSURLResponse * _Nullable response);// 返回URL的Block
typedef void (^ _Nullable DownLoadSuccess)(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath);// 下载成功的Blcok

/**
 对AF进行简单封装
 */
@interface SSNetworkingManager : AFHTTPSessionManager

/**
 单利方法

 @return 实例
 */
+(instancetype _Nonnull )shareManager;

/**
 *  封装的GET请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
- (void)GET:(NSString *_Nonnull)URLString parameters:(NSDictionary *_Nullable)parameters success:(Success)success failure:(Failure)failure;

/**
 *  封装的POST请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
- (void)POST:(NSString *_Nonnull)URLString parameters:(NSDictionary *_Nullable)parameters success:(Success)success failure:(Failure)failure;

/**
 *  封装POST图片上传(多张图片) // 可扩展成多个别的数据上传如:mp3等
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param picArray   存放图片模型(HDPicModle)的数组
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *_Nonnull)URLString parameters:(NSDictionary *_Nullable)parameters andPicArray:(NSArray *_Nullable)picArray progress:(Progress)progress success:(Success)success failure:(Failure)failure;

/**
 *  封装POST图片上传(单张图片) // 可扩展成单个别的数据上传如:mp3等
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param imageModle   上传的图片模型
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *_Nonnull)URLString parameters:(NSDictionary *_Nullable)parameters andPic:(SSImageModel *_Nullable)imageModle progress:(Progress)progress success:(Success)success failure:(Failure)failure;

/**
 *  封装POST上传url资源
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param imageModle   上传的图片模型(资源的url地址)
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *_Nonnull)URLString parameters:(NSDictionary *_Nullable)parameters andPicUrl:(SSImageModel *_Nullable)imageModle progress:(Progress)progress success:(Success)success failure:(Failure)failure;

/**
 *  下载
 *
 *  @param URLString       请求的链接
 *  @param progress        进度的回调
 *  @param destination     返回URL的回调
 *  @param downLoadSuccess 发送成功的回调
 *  @param failure         发送失败的回调
 */
- (NSURLSessionDownloadTask *_Nonnull)downLoadWithURL:(NSString *_Nonnull)URLString progress:(Progress)progress destination:(Destination)destination downLoadSuccess:(DownLoadSuccess)downLoadSuccess failure:(Failure)failure;

@end

SSNetworkingManager.m

//
//  SSNetworkingManager.m
//  SZSSV1
//
//  Created by DaLei on 2017/6/10.
//  Copyright © 2017年 DaLei. All rights reserved.
//

#import "SSNetworkingManager.h"
#import "SSImageModel.h"

@implementation SSNetworkingManager

+(instancetype)shareManager{
    static SSNetworkingManager *manager = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        manager = [[self alloc] initWithBaseURL:[NSURL URLWithString:URL_BASE]];
    });
    return manager;
}

/**
 重写父类方法

 @param url baseUrl
 @return 通过重写夫类的initWithBaseURL方法,返回网络请求类的实例
 */
-(instancetype)initWithBaseURL:(NSURL *)url{
    if (self = [super initWithBaseURL:url]) {
        /**设置请求超时时间*/
        self.requestSerializer.timeoutInterval = 30;
        
        /**设置相应的缓存策略*/
        self.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
        
        /**将token封装入请求头*/
        [self.requestSerializer setValue:@"TOKEN" forHTTPHeaderField:@"TOKENID"];
        
        /**设置可接受的类型*/
        [self.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/plain",@"application/json",@"text/json",@"text/javascript",@"text/html", nil]];
        
        /**设置请求和返回数据格式*/
        self.requestSerializer = [AFHTTPRequestSerializer serializer];
        self.responseSerializer = [AFJSONResponseSerializer serializer];
    }
    
    return self;
}

/**
 *  封装的get请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
- (void)GET:(NSString *)URLString parameters:(NSDictionary *)parameters success:(Success)success failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    
    [self GET:URLString parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            SSLog(@"请求成功,返回数据 : %@",responseObject);
            success(responseObject);
        }
        
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failure) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        }
        
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    }];
}

/**
 *  封装的POST请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
- (void)POST:(NSString *)URLString parameters:(NSDictionary *)parameters success:(Success)success failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; // 开启状态栏动画
    
    [self POST:URLString parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            SSLog(@"请求成功,返回数据 : %@",responseObject);
            success(responseObject);
        }
        
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; // 关闭状态栏动画
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failure) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        }
        
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; // 关闭状态栏动画
    }];
}

/**
 *  封装POST图片上传(多张图片) // 可扩展成多个别的数据上传如:mp3等
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param picArray   存放图片模型(HDPicModle)的数组
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *)URLString parameters:(NSDictionary *)parameters andPicArray:(NSArray *)picArray progress:(Progress)progress success:(Success)success failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    [self POST:URLString parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        NSInteger count = picArray.count;
        NSString *fileName = @"";
        NSData *data = [NSData data];
        
        for (int i = 0; i < count; i++) {
            @autoreleasepool {
                SSImageModel *picModle = picArray[i];
                fileName = [NSString stringWithFormat:@"pic%02d.jpg", i];
                
                /**
                 *  压缩图片然后再上传(1.0代表无损 0~~1.0区间)
                 */
                data = UIImageJPEGRepresentation(picModle.image, 1.0);
                
                [formData appendPartWithFileData:data name:picModle.imageName fileName:fileName mimeType:@"image/jpeg"];
                data = nil;
                picModle.image = nil;
            }
        }
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
        if (progress) {
            progress(uploadProgress); // HDLog(@"%lf", 1.0 * uploadProgress.completedUnitCount / uploadProgress.totalUnitCount);
        }
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            SSLog(@"请求成功,返回数据 : %@",responseObject);
            success(responseObject);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failure) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        }
    }];
}

/**
 *  封装POST图片上传(单张图片) // 可扩展成单个别的数据上传如:mp3等
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param picModle   上传的图片模型
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *)URLString parameters:(NSDictionary *)parameters andPic:(SSImageModel *)picModle progress:(Progress)progress success:(Success)success failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    [self POST:URLString parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        /**
         *  压缩图片然后再上传(1.0代表无损 0~~1.0区间)
         */
        NSData *data = UIImageJPEGRepresentation(picModle.image, 1.0);
        
        NSString *fileName = [NSString stringWithFormat:@"%@.jpg", picModle.imageName];
        
        [formData appendPartWithFileData:data name:picModle.imageName fileName:fileName mimeType:@"image/jpeg"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
        if (progress) {
            progress(uploadProgress);
            SSLog(@"%lf", 1.0 * uploadProgress.completedUnitCount / uploadProgress.totalUnitCount);
        }
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            SSLog(@"请求成功,返回数据 : %@",responseObject);
            success(responseObject);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failure) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        }
    }];
}

/**
 *  封装POST上传url资源
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param picModle   上传的图片模型(资源的url地址)
 *  @param progress   进度的回调
 *  @param success    发送成功的回调
 *  @param failure    发送失败的回调
 */
- (void)POST:(NSString *)URLString parameters:(NSDictionary *)parameters andPicUrl:(SSImageModel *)picModle progress:(Progress)progress success:(Success)success failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    [self POST:URLString parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        
        NSString *fileName = [NSString stringWithFormat:@"%@.jpg", picModle.imageName];
        // 根据本地路径获取url(相册等资源上传)
        NSURL *url = [NSURL fileURLWithPath:picModle.url]; // [NSURL URLWithString:picModle.url] 可以换成网络的图片在上传
        
        [formData appendPartWithFileURL:url name:picModle.imageName fileName:fileName mimeType:@"application/octet-stream" error:nil];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
        if (progress) {
            progress(uploadProgress);
            SSLog(@"%lf", 1.0 * uploadProgress.completedUnitCount / uploadProgress.totalUnitCount);
        }
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        if (success) {
            SSLog(@"请求成功,返回数据 : %@",responseObject);
            success(responseObject);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failure) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        }
    }];
}

/**
 *  下载
 *
 *  @param URLString       请求的链接
 *  @param progress        进度的回调
 *  @param destination     返回URL的回调
 *  @param downLoadSuccess 发送成功的回调
 *  @param failure         发送失败的回调
 */
- (NSURLSessionDownloadTask *)downLoadWithURL:(NSString *)URLString progress:(Progress)progress destination:(Destination)destination downLoadSuccess:(DownLoadSuccess)downLoadSuccess failure:(Failure)failure {
    
    SSLog(@"\n请求链接地址---> %@",URLString);
    
    NSURL *url = [NSURL URLWithString:URLString];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    // 下载任务
    NSURLSessionDownloadTask *task = [self downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
        
        if (progress) {
            progress(downloadProgress);
            SSLog(@"%lf", 1.0 * downloadProgress.completedUnitCount / downloadProgress.totalUnitCount);
        }
        
    } destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
        
        if (destination) {
            return destination(targetPath, response);
        } else {
            return nil;
        }
        
    } completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
        
        if (error) {
            SSLog(@"请求失败:%@",error);
            failure(error);
        } else {
            SSLog(@"请求成功,返回数据 : %@",response);
            downLoadSuccess(response, filePath);
        }
    }];
    
    // 开始启动任务
    [task resume];
    
    return task;
}


@end

测试类TestNetworkViewController

TestNetworkViewController.m

//
//  TestNetworkViewController.m
//  SZSSV1
//
//  Created by DaLei on 2017/6/13.
//  Copyright © 2017年 DaLei. All rights reserved.
//

#import "TestNetworkViewController.h"
#import "SSNetworkingManager.h"
#import "SSImageModel.h"

@interface TestNetworkViewController ()

@end

@implementation TestNetworkViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)GET:(id)sender{
    NSDictionary *dict = @{@"userName":@"xxx",@"password":@"yyy"};
    
    [[SSNetworkingManager shareManager] GET:@"app/login" parameters:dict success:^(id _Nullable responseObject) {
    } failure:^(NSError * _Nullable error) {
    }];
}

-(IBAction)POST:(id)sender{
    NSDictionary *dict = @{@"userName":@"xxx",@"password":@"yyy"};
    
    [[SSNetworkingManager shareManager] POST:@"app/register" parameters:dict success:^(id  _Nullable responseObject) {
    } failure:^(NSError * _Nullable error) {
    }];
}

-(IBAction)UPLOAD:(id)sender{
    NSDictionary *dict = @{@"userName":@"xxx",@"password":@"yyy"};
    SSImageModel *imageModel = [SSImageModel new];
    imageModel.imageName = @"imageFile";
    imageModel.image = [UIImage imageNamed:@"load1.png"];
    
    [[SSNetworkingManager shareManager] POST:@"app/upload" parameters:dict andPic:imageModel progress:^(NSProgress * _Nullable progress) {
        
    } success:^(id  _Nullable responseObject) {
        
    } failure:^(NSError * _Nullable error) {
        
    }];
}

-(IBAction)UPLOADS:(id)sender{
    NSDictionary *dict = @{@"userName":@"xxx",@"password":@"yyy"};
    
    SSImageModel *imageModel1 = [SSImageModel new];
    imageModel1.imageName = @"imageFile";
    imageModel1.image = [UIImage imageNamed:@"load1.png"];
    
    SSImageModel *imageModel2 = [SSImageModel new];
    imageModel2.imageName = @"imageFile";
    imageModel2.image = [UIImage imageNamed:@"load2.png"];
    
    SSImageModel *imageModel3 = [SSImageModel new];
    imageModel3.imageName = @"imageFile";
    imageModel3.image = [UIImage imageNamed:@"load3.png"];
    
    NSArray *array = @[imageModel1,imageModel2,imageModel3];
    
    [[SSNetworkingManager shareManager] POST:@"app/uploads" parameters:dict andPicArray:array progress:^(NSProgress * _Nullable progress) {
        
    } success:^(id  _Nullable responseObject) {
        
    } failure:^(NSError * _Nullable error) {
        
    }];
}

-(IBAction)UPLOADURL:(id)sender{
    NSDictionary *dict = @{@"userName":@"xxx",@"password":@"yyy"};
    SSImageModel *imageModel1 = [SSImageModel new];
    NSString *newPath=[[NSBundle mainBundle] pathForResource:@"Icon@3x" ofType:@"png"];
    imageModel1.url = newPath;
    imageModel1.imageName = @"imageFile";
    
    [[SSNetworkingManager shareManager] POST:@"app/upload" parameters:dict andPicUrl:imageModel1 progress:^(NSProgress * _Nullable progress) {
        
    } success:^(id  _Nullable responseObject) {
        
    } failure:^(NSError * _Nullable error) {
        
    }];
    
}

-(IBAction)DOWNLOAD:(id)sender{
    
    [[SSNetworkingManager shareManager] downLoadWithURL:@"http://localhost:8080/moxi-0.0.1-SNAPSHOT/userfiles/20170612110517.png" progress:^(NSProgress * _Nullable progress) {
        
    } destination:^NSURL * _Nullable(NSURL * _Nullable targetPath, NSURLResponse * _Nullable response) {
        
        NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];

        return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
        
    } downLoadSuccess:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath) {
        
        NSLog(@"response:%@,filePath:%@",response,filePath);
        
        //判断目录里面是否存在这个图片
        NSFileManager*fileManager = [NSFileManager defaultManager];
        BOOL isFile = [fileManager fileExistsAtPath:[filePath path]];
        if (isFile) {
            //更新界面需要使用主线程
            dispatch_async(dispatch_get_main_queue(), ^{
                //设置图片视图的的图片
                self.imageVC.image = [UIImage imageWithContentsOfFile:[filePath path]];
            });
        }
        
    } failure:^(NSError * _Nullable error) {
        
    }];
}


@end

执行结果

测试结果
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,591评论 18 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 46,732评论 6 342
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,016评论 4 62
  • 遥念佳人绕渚起舞 归思之处 皆是苦楚泪 是不可与沙漠之水 与鱼恋之水 与春日缠绵之水 相语 落 是花开落时 起 是...
    李子柚阅读 180评论 0 0
  • 转载自网络
    AliceHuang阅读 111评论 0 0