All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.sylinx.hbatis.kit.Ret Maven / Gradle / Ivy

There is a newer version: 2.0.0.RELEASE
Show newest version
package cn.sylinx.hbatis.kit;

import java.io.Serializable;

public class Ret implements Serializable {

	private boolean success = false;

	private String error;

	private Object data;
	
	private int code = 500;

	public Ret() {

	}

	public Ret(boolean success, String error, Object data) {
		this.success = success;
		this.error = error;
		this.data = data;
	}
	

	public Ret(boolean success, String error, Object data, int code) {
		this.success = success;
		this.error = error;
		this.data = data;
		this.code = code;
	}


	public static Ret error() {
		return new Ret(false, "执行失败", null, 500);
	}

	public static Ret error(String error) {
		return new Ret(false, error, null, 500);
	}
	
	public static Ret error(int code, String error) {
		return new Ret(false, error, null, code);
	}

	public static Ret success() {
		return new Ret(true, "成功执行", null, 200);
	}

	public static Ret success(Object data) {
		return new Ret(true, "成功执行", data, 200);
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy