这是本人常用的返回数据类
package com.pobo.pbcfgcenter.manage.domain;
import com.pobo.pbcfgcenter.manage.utils.Constants;
import java.io.Serializable;
public class Result<T> implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7938378478392182545L;
private int errorCode;
private String msg;
private T body;
public static Result ofSuccess() {
return new Result(Constants.RET_OK,"success");
}
public static Result ofSuccess(String msg) {
return new Result(Constants.RET_OK,msg);
}
public static Result ofFailure(int errcode,String errmsg) {
return new Result(errcode,errmsg);
}
public int getErrorCode() {
return errorCode;
}
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getBody() {
return body;
}
public Result setBody(T body) {
this.body = body;
return this;
}
public Result(int errorCode,String msg) {
super();
this.errorCode = errorCode;
this.msg = msg;
}
public Result() {
super();
}
public Result(int errorCode,String msg,T body) {
super();
this.errorCode = errorCode;
this.msg = msg;
this.body = body;
}
public Result(int errorCode,String token,T body) {
super();
this.errorCode = errorCode;
this.msg = msg;
this.body = body;
}
}
原文地址:https://blog.csdn.net/qq_40006446
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。