package com.wdkl.ncs.android.middleware.model;

import java.io.Serializable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 描述
 *
 * @author allen
 * 2019-03-29 15:34
 */
@ApiModel("接口操作结果返回对象")
public class JsonResponse implements Serializable {
    //成功失败标识
    @ApiModelProperty("操作结果成功与否标识")
    public boolean success;
    //一般用于失败时的错误提示
    @ApiModelProperty("操作结果消息提示")
    public String message;
    //返回的对象
    @ApiModelProperty("操作结果返回对象")
    public Object data;

    public JsonResponse() {
    }

    public static JsonResponse successResponse() {
        JsonResponse response = new JsonResponse();
        response.success = true;
        return response;
    }

    public static JsonResponse successResponse(Object data) {
        JsonResponse response = new JsonResponse();
        response.success = true;
        response.data = data;
        return response;
    }

    public static JsonResponse successResponse(String message, Object data) {
        JsonResponse response = new JsonResponse();
        response.success = true;
        response.message = message;
        response.data = data;
        return response;
    }

    public static JsonResponse errorResponse(String message) {
        JsonResponse response = new JsonResponse();
        response.success = false;
        response.message = message;
        return response;
    }
}
