All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.github.wzc789376152.vo.RetResult Maven / Gradle / Ivy
package com.github.wzc789376152.vo;
import lombok.Data;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
import java.util.UUID;
@Data
public class RetResult implements Serializable, Cloneable {
// 请求流水号
private String requestId;
public String getRequestId() {
if (StringUtils.isNotEmpty(requestId)) {
return requestId;
}
return UUID.randomUUID().toString().replace("-", "");
}
public Integer code;
private String message;
private T data;
public RetResult(String requestId, Integer code, String msg, T data) {
this.code = code;
this.message = msg;
this.data = data;
this.requestId = requestId;
}
public static RetResult success() {
return success(null, null, null);
}
public static RetResult success(String uuid, T data) {
return success(uuid, data, null);
}
public static RetResult success(T data) {
return success(data, null);
}
public static RetResult success(T data, String message) {
return success(null, data, message);
}
public static RetResult success(String uuid, T data, String message) {
return new RetResult<>(uuid, 200, message, data);
}
public static RetResult failed(String msg) {
return failed(null, 500, msg, null);
}
public static RetResult failed(String uuid, T data) {
return failed(uuid, 500, null, data);
}
public static RetResult failed(Integer code, String msg, T data) {
return failed(null, code, msg, data);
}
public static RetResult failed(String uuid, Integer code, String msg, T data) {
return new RetResult<>(uuid, code, msg, data);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
@Override
public Object clone() {
return SerializationUtils.clone(this);
}
}