first init
This commit is contained in:
42
src/main/java/com/yupi/project/common/BaseResponse.java
Normal file
42
src/main/java/com/yupi/project/common/BaseResponse.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.yupi.project.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 通用返回类
|
||||
*
|
||||
* @param <T>
|
||||
* @author yupi
|
||||
*/
|
||||
@Data
|
||||
public class BaseResponse<T> implements Serializable {
|
||||
|
||||
private int code;
|
||||
|
||||
private T data;
|
||||
|
||||
private String message;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user