标签:turn zab final mem 返回 class author long dem
package com.demo.common.beans;
import lombok.Data;
import java.io.Serializable;
/**
* @author zys
*/
@Data
public class ResultJson<T> implements Serializable {
private static final long serialVersionUID = 1L;
public static final int SUCCESS = 0;
public static final int FAIL = 1;
private String msg = "success";
private int code = SUCCESS;
private long timestamp;
private T data;
public ResultJson() {
super();
}
public ResultJson(T data) {
super();
this.data = data;
this.timestamp = System.currentTimeMillis();
}
public ResultJson(Throwable e) {
super();
this.msg = e.toString();
this.code = FAIL;
}
public static <T> ResultJson<T> ok(T data){
ResultBean<T> rj = new ResultBean<>();
rj.code = SUCCESS;
rj.msg = "success";
rj.timestamp = System.currentTimeMillis();
rj.data = data;
return rj;
}
public static ResultJson ok(){
ResultBean rj = new ResultBean();
rj.code = SUCCESS;
rj.msg = "success";
rj.timestamp = System.currentTimeMillis();
return rj;
}
public static ResultJson error(String msg){
ResultBean rj = new ResultBean();
rj.code = FAIL;
rj.msg = msg;
rj.timestamp = System.currentTimeMillis();
return rj;
}
public static ResultJson error(int code,String msg){
ResultBean rj = new ResultBean();
rj.code = code;
rj.msg = msg;
rj.timestamp = System.currentTimeMillis();
return rj;
}
}
标签:turn zab final mem 返回 class author long dem
原文地址:https://www.cnblogs.com/zysnba/p/14604731.html