Files
TraceabilityCode-houduan/src/main/java/org/traceability/common/BaseResponse.java
2025-07-22 11:40:09 +08:00

43 lines
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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());
}
}