You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
Java
56 lines
1.2 KiB
Java
package com.sztzjy.util;
|
|
|
|
import lombok.Getter;
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
/**
|
|
* 出参对象统一封装
|
|
*/
|
|
@Getter
|
|
public class ResultDataEntity<T> {
|
|
/**
|
|
* 状态码
|
|
*/
|
|
private final Integer code;
|
|
/**
|
|
* 异常提示
|
|
*/
|
|
// @JsonInclude(JsonInclude.Include.NON_NULL)
|
|
private String msg = null;
|
|
/**
|
|
* 返回体对象
|
|
*/
|
|
// @JsonInclude(JsonInclude.Include.NON_NULL)
|
|
private T data = null;
|
|
|
|
public ResultDataEntity(T data) {
|
|
this.code = HttpStatus.OK.value();
|
|
this.data = data;
|
|
}
|
|
|
|
public ResultDataEntity(HttpStatus status, T data) {
|
|
this.code = status.value();
|
|
this.data = data;
|
|
}
|
|
|
|
public ResultDataEntity(HttpStatus status, String msg, T data) {
|
|
this.code = status.value();
|
|
this.msg = msg;
|
|
this.data = data;
|
|
}
|
|
|
|
public ResultDataEntity(String msg) {
|
|
this.code = HttpStatus.OK.value();
|
|
this.msg = msg;
|
|
}
|
|
|
|
public ResultDataEntity(HttpStatus status, String msg) {
|
|
this.code = status.value();
|
|
this.msg = msg;
|
|
}
|
|
|
|
public ResultDataEntity(HttpStatus status) {
|
|
this.code = status.value();
|
|
}
|
|
}
|