数据处理
Posted gavin-yao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据处理相关的知识,希望对你有一定的参考价值。
public class Result<T> {
private Status status;
private T data;
public Result() {
}
public Result(Status status) {
this.status = status;
}
public Result(Status status, T data) {
this.status = status;
this.data = data;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public static Result ok() {
return new Result(Status.ok());
}
public static <T> Result<T> ok(T data) {
return new Result(Status.ok(), data);
}
public static <T> Result<T> paramsInvalid() {
return new Result(Status.paramsInvalid());
}
public static <T> Result<T> notFound() {
return new Result(Status.notFound());
}
public static <T> Result<T> error() {
return new Result(Status.error());
}
public static <T> Result<T> error(String errorMsg) {
return new Result(Status.error(errorMsg));
}
public static <T> Result<T> error(String errorMsg,T data) {
return new Result(Status.error(errorMsg),data);
}
public static <T> Result<T> error(int code, String errorMsg) {
return new Result(new Status(code, errorMsg));
}
public static <T> Result<T> result(int code, String msg) {
return new Result(new Status(code, msg));
}
public static <T> Result<T> result(int code, String msg, T data) {
return new Result(new Status(code, msg), data);
}
}
public class DataList<T> {
private List<T> data;
private int total;
public DataList() {
}
public DataList(List<T> data, int total) {
this.total = total;
this.data = data;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
}
以上是关于数据处理的主要内容,如果未能解决你的问题,请参考以下文章