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

com.leftins.tools.result.Result Maven / Gradle / Ivy

There is a newer version: 1.1.6
Show newest version
package com.leftins.tools.result;


import com.leftins.tools.constant.RequestConstant;

public class Result {
    public Result() {
    }

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    private Integer code;
    private String message;
    private T data;

    public static Result NotFound() {
        return new Result<>(-1, "对象不存在", null);
    }

    public static Result AuthNotAllow() {
        return new Result<>(-1, "auth not allow", null);
    }

    public static Result VersionNotAllow() {
        return new Result<>(-1, "当前版本过低,请升级后再试", null);
    }

    public static Result Success(Object data) {
        return new Result(RequestConstant.SUCCESSCODE, "获取成功", data);
    }

    public static Result Success(String message, Object data) {
        return new Result(RequestConstant.SUCCESSCODE, message, data);
    }

    public Integer getCode() {
        return code;
    }

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

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

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