package com.gree.mall.miniapp.helper;

import io.swagger.annotations.ApiModel;

@ApiModel
public class ResponseHelper<T> {


    public final static int ResponseCode_Success = 200;
    public final static int ResponseCode_COMMON = 501;//通用拦截提示
    public final static int ResponseCode_AUTH_ERROR = 1001;//非法请求
    public final static int ResponseCode_NOT_PHONE = 4001;//未找到师傅手机号

    //无权限访问
    public final static int NOT_PERMISSION = 2001;

    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 success(int code, Object data) {
        ResponseHelper object = new ResponseHelper(ResponseCode_Success, "success");
        object.setData(data);
        object.setCode(code);
        return object;
    }

    public static ResponseHelper success(int code, Object data, String msg) {
        ResponseHelper object = new ResponseHelper(ResponseCode_Success, "success");
        object.setData(data);
        object.setCode(code);
        object.setMessage(msg);
        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;
    }

}
