package com.zfire.jiasm.syncdata.utils;

import io.swagger.annotations.ApiModel;

@ApiModel
public class ResponseHelper<T> {


    public static int ResponseCode_Success = 1; //成功
    public static int ResponseCode_COMMON = 501;//通用拦截提示
    public static int ResponseCode_AUTH_ERROR = 130;//非法请求

    private T data;
    private String message;
    private int code;


    public static ResponseHelper success() {
        ResponseHelper object = new ResponseHelper(ResponseCode_Success, "success");
        return object;
    }

    public static ResponseHelper success(Object data) {
        ResponseHelper object = new ResponseHelper(ResponseCode_Success, "success");
        object.setData(data);
        return object;
    }

    public static ResponseHelper error(String msg) {
        ResponseHelper object = new ResponseHelper(ResponseCode_COMMON, msg);
        return object;
    }

    public static ResponseHelper error(int code, String msg) {
        ResponseHelper object = new ResponseHelper(code, msg);
        return object;
    }

    public T getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = (T)data;
    }

    public ResponseHelper(int code, String message) {
        this.code = code;
        this.message = message;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int status) {
        this.code = status;
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
