package net.educoder.ecsonar.utils;

import java.io.Serializable;

/**
 * @Author: youys
 * @Date: 2022/1/17
 * @Description:
 */
public class ResponseResult<T> implements Serializable {

    private Integer code;
    private String msg;
    private T data;


    public ResponseResult(){

    }
    public ResponseResult(Integer code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public ResponseResult(T data){
        this.code = 1;
        this.msg = "";
        this.data = data;
    }

    public static ResponseResult success(){
        return new ResponseResult(0,"success");
    }


    public static <T> ResponseResult success(T data){
        return new ResponseResult(data);
    }

    public static ResponseResult error(String msg){
        return new ResponseResult(-1,msg);
    }

    public Integer getCode() {
        return code;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

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