栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

常用的返回类

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

常用的返回类

这是本人常用的返回数据类

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;
	}					
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/673087.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号