43 lines
1.1 KiB
Java
43 lines
1.1 KiB
Java
package org.traceability.common;
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema;
|
||
import lombok.Data;
|
||
|
||
import java.io.Serializable;
|
||
|
||
@Data
|
||
@Schema(description = "通用返回对象")
|
||
public class BaseResponse<T> implements Serializable {
|
||
|
||
@Schema(description = "状态码,例如:200 表示成功")
|
||
private int code;
|
||
|
||
@Schema(description = "返回的数据内容")
|
||
private T data;
|
||
|
||
@Schema(description = "提示消息")
|
||
private String message;
|
||
|
||
@Schema(description = "错误描述")
|
||
private String description;
|
||
|
||
public BaseResponse(int code, T data, String message, String description) {
|
||
this.code = code;
|
||
this.data = data;
|
||
this.message = message;
|
||
this.description = description;
|
||
}
|
||
|
||
public BaseResponse(int code, T data, String message) {
|
||
this(code, data, message, "");
|
||
}
|
||
|
||
public BaseResponse(int code, T data) {
|
||
this(code, data, "", "");
|
||
}
|
||
|
||
public BaseResponse(ErrorCode errorCode) {
|
||
this(errorCode.getCode(), null , errorCode.getMessage(), errorCode.getDescription());
|
||
}
|
||
}
|