常用的返回类

常用的返回类,第1张

常用的返回

这是本人常用的返回数据

package com.pobo.pbcfgcenter.manage.domain;

import com.pobo.pbcfgcenter.manage.utils.Constants;
import java.io.Serializable;
public class Result 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 msg, String token, T body) {
		super();
		this.errorCode = errorCode;
		this.msg = msg;
		this.body = body;
	}					
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5678309.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存