File was renamed from src/main/java/com/ycl/jxkg/base/RestResponse.java |
| | |
| | | * Copyright (C), 2020-2024, 武汉思维跳跃科技有限公司 |
| | | * @date 2021/5/25 10:45 |
| | | */ |
| | | public class RestResponse<T> { |
| | | public class Result<T> { |
| | | private int code; |
| | | private String message; |
| | | private T response; |
| | |
| | | * @param code the code |
| | | * @param message the message |
| | | */ |
| | | public RestResponse(int code, String message) { |
| | | public Result(int code, String message) { |
| | | this.code = code; |
| | | this.message = message; |
| | | } |
| | |
| | | * @param message the message |
| | | * @param response the response |
| | | */ |
| | | public RestResponse(int code, String message, T response) { |
| | | public Result(int code, String message, T response) { |
| | | this.code = code; |
| | | this.message = message; |
| | | this.response = response; |
| | |
| | | * @param msg the msg |
| | | * @return the rest response |
| | | */ |
| | | public static RestResponse fail(Integer code, String msg) { |
| | | return new RestResponse<>(code, msg); |
| | | public static Result fail(Integer code, String msg) { |
| | | return new Result<>(code, msg); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the rest response |
| | | */ |
| | | public static RestResponse ok() { |
| | | public static Result ok() { |
| | | SystemCode systemCode = SystemCode.OK; |
| | | return new RestResponse<>(systemCode.getCode(), systemCode.getMessage()); |
| | | return new Result<>(systemCode.getCode(), systemCode.getMessage()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param response the response |
| | | * @return the rest response |
| | | */ |
| | | public static <F> RestResponse<F> ok(F response) { |
| | | public static <F> Result<F> ok(F response) { |
| | | SystemCode systemCode = SystemCode.OK; |
| | | return new RestResponse<>(systemCode.getCode(), systemCode.getMessage(), response); |
| | | return new Result<>(systemCode.getCode(), systemCode.getMessage(), response); |
| | | } |
| | | |
| | | /** |