Results returned unified package java class

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

Released seven original articles · won praise 3 · Views 193

Guess you like

Origin blog.csdn.net/qq_39491096/article/details/104014546