| | |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @author wMeng |
| | | * @ClassName Result |
| | | * @Description TODO |
| | | * @date 2022/10/30 13:29 |
| | | * @Version 1.0 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "通用结果集",description = "通用结果集") |
| | | public class Result<T> implements Serializable { |
| | |
| | | @ApiModelProperty(value = "数据对象") |
| | | private T result; |
| | | |
| | | @ApiModelProperty(value = "记录数") |
| | | private Integer count = 0; |
| | | |
| | | /** |
| | | * 时间戳 |
| | | */ |
| | |
| | | |
| | | @Deprecated |
| | | public static Result<Object> ok(String msg) { |
| | | Result<Object> r = new Result<Object>(); |
| | | Result<Object> r = new Result<>(); |
| | | r.setSuccess(true); |
| | | r.setCode(CommonConstant.SC_OK_200); |
| | | r.setMessage(msg); |
| | |
| | | |
| | | @Deprecated |
| | | public static Result<Object> ok(Object data) { |
| | | Result<Object> r = new Result<Object>(); |
| | | Result<Object> r = new Result<>(); |
| | | r.setSuccess(true); |
| | | r.setCode(CommonConstant.SC_OK_200); |
| | | r.setResult(data); |
| | | return r; |
| | | } |
| | | |
| | | public static<T> Result<T> OK() { |
| | | public static Result<Object> OK(Integer count, Object data) { |
| | | Result<Object> r = ok(data); |
| | | r.setCount(count); |
| | | |
| | | return r; |
| | | } |
| | | |
| | | public static <T> Result<T> OK() { |
| | | Result<T> r = new Result<T>(); |
| | | r.setSuccess(true); |
| | | r.setCode(CommonConstant.SC_OK_200); |
| | |
| | | return r; |
| | | } |
| | | |
| | | public static<T> Result<T> OK(T data) { |
| | | public static <T> Result<T> OK(T data) { |
| | | Result<T> r = new Result<T>(); |
| | | r.setSuccess(true); |
| | | r.setCode(CommonConstant.SC_OK_200); |
| | |
| | | return r; |
| | | } |
| | | |
| | | public static<T> Result<T> OK(String msg, T data) { |
| | | public static <T> Result<T> OK(String msg, T data) { |
| | | Result<T> r = new Result<T>(); |
| | | r.setSuccess(true); |
| | | r.setCode(CommonConstant.SC_OK_200); |
| | |
| | | return r; |
| | | } |
| | | |
| | | public static<T> Result<T> error(String msg, T data) { |
| | | public static <T> Result<T> error(String msg, T data) { |
| | | Result<T> r = new Result<T>(); |
| | | r.setSuccess(false); |
| | | r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500); |
| | |
| | | this.success = false; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * 无权限访问返回结果 |
| | | */ |
| | |
| | | return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg); |
| | | } |
| | | |
| | | @JsonIgnore |
| | | private String onlTable; |
| | | public boolean isSuccess() { |
| | | return success; |
| | | } |
| | | |
| | | public void setSuccess(boolean success) { |
| | | this.success = success; |
| | | } |
| | | |
| | | public String getMessage() { |
| | | return message; |
| | | } |
| | | |
| | | public void setMessage(String message) { |
| | | this.message = message; |
| | | } |
| | | |
| | | public Integer getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public void setCode(Integer code) { |
| | | this.code = code; |
| | | } |
| | | |
| | | public T getResult() { |
| | | return result; |
| | | } |
| | | |
| | | public void setResult(T result) { |
| | | this.result = result; |
| | | } |
| | | |
| | | public Integer getCount() { |
| | | return count; |
| | | } |
| | | |
| | | public void setCount(Integer count) { |
| | | this.count = count; |
| | | } |
| | | |
| | | public long getTimestamp() { |
| | | return timestamp; |
| | | } |
| | | |
| | | public void setTimestamp(long timestamp) { |
| | | this.timestamp = timestamp; |
| | | } |
| | | } |