一个常用的可能都很标准的东西

@Getter
@ToString
@AllArgsConstructor
public enum BaseResponseEnum {
    CODE_SUCCESS(10000,"请求成功"),
    CODE_FAIL(10001,"请求失败"),
    CODE_NOT_ALLOW(10002,"拒绝请求"),
    CODE_TIMEOUT(10003,"请求超时"),
    CODE_EXPIRE(10004,"登录超时");

    private Integer code;
    private String msg;
}
@Data
public class BaseResponse<T> {

    private Boolean success;
    private Integer code;
    private String msg;
    private T data;

    public static BaseResponse success(){
        BaseResponse response = new BaseResponse();
        response.setSuccess(true);
        response.setCode(BaseResponseEnum.CODE_SUCCESS.getCode());
        return response;
    }

    public static BaseResponse fail(){
        BaseResponse response = new BaseResponse();
        response.setSuccess(false);
        response.setCode(BaseResponseEnum.CODE_FAIL.getCode());
        return response;
    }

    public BaseResponse msg(String msg){
        this.msg = msg;
        return this;
    }

    public BaseResponse<T> data(T data){
        this.data = data;
        return this;
    }

}