```
public class ResultEntity {
private Integer code;
private String message;
private Object data;
@
JsonIgnore private HttpStatus status;
@
JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private LocalDateTime datetime;
}
```
个人项目的话。GET 以外的方法结果为 20x 的时候,除特殊情况什么都不返回,GET 只返回内容,没有上面的封装。有错误的时候才上面封装的内容。status 是方便在 service 层返回状态给 controller 用的,实际是会以 http 状态码返回给前端。会用到 GET POST DELETE PUT PATCH 五种 Method 。
```
public class ResultEntity implements Serializable {
private boolean success;
private String errorMsg;
private int errorCode;
private String errorLevel;
private Object content;
}
public class PageResultEntity implements Serializable {
private int currentPage;
private int pageSize;
private long totalCount;
private int pages;
private List<Object> data;
}
```
工作嘛,全用 GET POST,全返回 200,然后就是上面定义的内容了。