使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre

简介: 使用result类一定要添加@Data注解“timestamp“:“2023-09-07T07:57:57.497+00:00““status“: 406,No acceptable repre

1、

必须添加@Data

result类:

package worldtolingyidianke.file.bean;
 
 
 
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Data;
 
//统一响应结果
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result<T> {
    private Integer code;//业务状态码  0-成功  1-失败
    private String message;//提示信息
    private T data;//响应数据
 
    //快速返回操作成功响应结果(带响应数据)
    //快速返回操作成功响应结果(带响应数据)
    public static <E> Result<E> success(E data) {
        return new Result<>(0, "操作成功", data);
    }
 
    //快速返回操作成功响应结果
    public static Result success() {
        return new Result(0, "操作成功", null);
    }
 
    public static Result error(String message) {
        return new Result(1, message, null);
    }
}
 
相关文章
|
6月前
|
SQL IDE Java
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
74 0
|
6月前
|
API Android开发 开发者
failed to set system property error code: 0x18
failed to set system property error code: 0x18
285 1
|
Java
【ES异常】mapper [sortNum] of different type, current_type [long], merged_type [keyword]
【ES异常】mapper [sortNum] of different type, current_type [long], merged_type [keyword]
143 0
|
6月前
|
druid Java
Error attempting to get column ‘createTime‘ from result set的异常
Error attempting to get column ‘createTime‘ from result set的异常
418 0
|
人工智能 自然语言处理 语音技术
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
120 0
|
SQL Java 数据库连接
attempted to return null from a method with a primitive return type
attempted to return null from a method with a primitive return type
189 0