package com.luky.vo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import org.springframework.http.HttpStatus; @Data @ToString @AllArgsConstructor @NoArgsConstructor public class Response<T> { /** * 错误码 */ private int errorCode; /** * 错误信息 */ private String errorMsg; /** * 数据 */ private T data; public static <T> Response<T> ok(T data) { return new Response<>(HttpStatus.OK.value(), "OK", data); } public static <T> Response<T> ok(int errorCode, T data) { return new Response<>(errorCode, "OK", data); } public static <T> Response<T> ok(int code, String msg, T data) { return new Response<>(code, msg, data); } public static <T> Response<T> ok() { return new Response<>(HttpStatus.OK.value(), null, null); } public static <T> Response<T> fail(int errorCode, String errorMsg, T data) { return new Response<>(errorCode, errorMsg, data); } public static <T> Response<T> fail(int errorCode, String errorMsg) { return new Response<>(errorCode, errorMsg, null); } }
标签:实体类,return,SpringBoot,Response,errorCode,static,data,public From: https://www.cnblogs.com/wnhbx/p/18160903