@Date
public class Response<T> implements Serializable{
private static final long serialVersionUID = 1257916683118688101L;
private Integer code;
private String msg;
private T data;
public Response() {
this.code = ResultEnum.SUCCESS.code;
this.msg = ResultEnum.SUCCESS.msg;
}
public Response(T data) {
this.code = ResultEnum.SUCCESS.getCode();
this.msg = ResultEnum.SUCCESS.getMsg();
this.data = data;
}
public Response(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Response(Integer code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
}
public static Response<RestEnum> success() {
return new BdpServiceResponse(BdpResponseEnum.SUCCESS);
}
public static <T> Response<T> success(T data) {
return new Response(data);
}
public static <T> BdpServiceResponse<T> success(T data, int code, String msg) {
return new Response(data, code, msg);
}
public static <T> Response<T> failure() {
return new Response(ResultEnum.FAILURE.getCode(), ResultEnum.FAILURE.getMsg());
}
public static <T> Response<T> failure(int code, String msg) {
return failure((Object)null, code, msg);
}
public static <T> Response<T> failure(T data, int code, String msg) {
return new Response((Object)null, code, msg);
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof BdpServiceResponse)) {
return false;
} else {
BdpServiceResponse<?> other = (BdpServiceResponse)o;
if (!other.canEqual(this)) {
return false;
} else if (this.getCode() != other.getCode()) {
return false;
} else {
Object this$msg = this.getMsg();
Object other$msg = other.getMsg();
if (this$msg == null) {
if (other$msg != null) {
return false;
}
} else if (!this$msg.equals(other$msg)) {
return false;
}
Object this$data = this.getData();
Object other$data = other.getData();
if (this$data == null) {
if (other$data != null) {
return false;
}
} else if (!this$data.equals(other$data)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof BdpServiceResponse;
}
public int hashCode() {
int PRIME = true;
int result = 1;
int result = result * 59 + this.getCode();
Object $msg = this.getMsg();
result = result * 59 + ($msg == null ? 43 : $msg.hashCode());
Object $data = this.getData();
result = result * 59 + ($data == null ? 43 : $data.hashCode());
return result;
}
}
public enum ResultEnum {
SUCCESS(0, "操作成功."),
FAILURE(201, "操作失败."),
PARAM_ERROR(202, "参数错误."),
UNKNOWN_ERROR(203, "未知错误."),
DATABASE_ERROR(204, "数据库操作异常."),
ILLEGAL(205, "非法操作.");
@Getter
private int code;
@Getter
private String msg;
ResultEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
}