Commit 7a001bed authored by wujipeng's avatar wujipeng
Browse files

响应体优化

parent e6351ce8
......@@ -2,41 +2,35 @@ package com.ruzhoukj.knowledgegraph.result;
public class Response<T> {
private boolean success;
private Integer code;
private String message;
private T data;
private Integer total;
public Response() {
}
public Response(boolean success, String message, T data) {
this.success = success;
public Response(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public static <T> Response<T> success(T data) {
return new Response<>(true, "操作成功", data);
}
public static <T> Response<T> success(T data, int total) {
Response<T> response = new Response<>(true, "操作成功", data);
response.setTotal(total);
return response;
return new Response<>(200, "操作成功", data);
}
public static <T> Response error(String message) {
return new Response<>(false, message, null);
return new Response<>(400, message, null);
}
// Getters and Setters
public boolean isSuccess() {
return success;
public Integer getCode() {
return code;
}
public void setSuccess(boolean success) {
this.success = success;
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
......@@ -55,11 +49,5 @@ public class Response<T> {
this.data = data;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment