1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| package online.orange.blog.common.base;
import lombok.Data; import online.orange.blog.common.constants.ResponseCode; @Data public class Result<T> { private String code; private String msg; private T data;
public static <T> Result<T> success(T data) { Result<T> result = new Result<>(); result.setCode(ResponseCode.SUCCESS); result.setMsg("success"); result.setData(data); return result; }
public static Result<Void> success() { return success(null); }
public static <T> Result<T> error(String code, String message) { Result<T> result = new Result<>(); result.setCode(code); result.setMsg(message); return result; }
public static <T> Result<T> error(String message) { return error(ResponseCode.FAIL, message); }
}
|