package com.xxfc.platform.vehicle.common;

import com.github.wxiaoqi.security.common.msg.BaseResponse;

public class RestResponse<T> extends BaseResponse {

    public static final Integer SUC_CODE = 1;

    T data;
    Integer code;

    public RestResponse(){
        code = SUC_CODE;
    }

    public static <M> RestResponse<M> sucResponse(){
        return new RestResponse<M>();
    }

    public T getData() {
        return data;
    }

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

    public Integer getCode() {
        return code;
    }

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


    public static <M> RestResponse<M> data(M data){
        RestResponse<M> restResponse = new RestResponse<M>();
        restResponse.setData(data);
        return restResponse;
    }

    public static <M> RestResponse<M> suc(){
        return new RestResponse<M>();
    }

    public static <M> RestResponse<M> suc(M data){
        RestResponse<M> restResponse = new RestResponse<M>();
        restResponse.setData(data);
        return restResponse;
    }

    public static <M> RestResponse<M> code(Integer code){
        RestResponse<M> restResponse = new RestResponse<M>();
        restResponse.setCode(code);
        return restResponse;
    }

    public static <M> RestResponse<M> codeAndData(Integer code,M data){
        RestResponse<M> restResponse = new RestResponse<M>();
        restResponse.setCode(code);
        restResponse.setData(data);
        return restResponse;
    }

    public static <M> RestResponse<M> codeAndMessage(Integer code,String msg){
        RestResponse<M> restResponse = new RestResponse<M>();
        restResponse.setCode(code);
        restResponse.setMessage(msg);
        return restResponse;
    }

}
