java返回统一结果封装类

package com.sensebling.common.util;

import java.io.Serializable;

@SuppressWarnings("serial")
public class Result implements Serializable{

	private String res = "-1";
	private String error = "系统异常";
	private String message = "系统异常";
	private Object data;
	private boolean success = false;
	
	public Result() {
		
	}
	public Result success() {
		this.setRes("0");   
		this.success = true;
		return this;
	}
	public Result error(String error) {
		this.error = error;
		return this;
	}
	public Result(String res,String error) {
		this.res = res;
		this.error = error;
		this.message = error;
		this.success = "0".equals(res);
	}
	public boolean isSuccess() {
		return success;
	}
	public String getRes() {
		return res;
	}
	public void setRes(String res) {
		this.res = res;
		this.success = "0".equals(res);
	}
	public String getError() {
		return error;
	}
	public void setError(String error) {
		this.error = error;
		this.message = error;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public String getMessage() {
		return message;
	}
}

发布了7 篇原创文章 · 获赞 3 · 访问量 193

猜你喜欢

转载自blog.csdn.net/qq_39491096/article/details/104014546