feature(cofiguration): 分页增加额外的参数
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.lanyuanxiaoyao.service.configuration.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分页实体类
|
||||
@@ -12,6 +14,7 @@ import java.util.List;
|
||||
public class PageResponse<T> {
|
||||
private List<T> data = new ArrayList<>(0);
|
||||
private Long total = 0L;
|
||||
private Map<String, Object> metadata = new HashMap<>();
|
||||
|
||||
public PageResponse() {
|
||||
}
|
||||
@@ -22,10 +25,15 @@ public class PageResponse<T> {
|
||||
}
|
||||
|
||||
public PageResponse(List<T> data, Long total) {
|
||||
this.data = data;
|
||||
this(data);
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public PageResponse(List<T> data, Long total, Map<String, Object> metadata) {
|
||||
this(data, total);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public List<T> getData() {
|
||||
return data;
|
||||
}
|
||||
@@ -42,11 +50,25 @@ public class PageResponse<T> {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public Map<String, Object> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Map<String, Object> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public PageResponse<T> withMetadata(String key, Object value) {
|
||||
this.metadata.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PageResponse{" +
|
||||
"data=" + data +
|
||||
", total=" + total +
|
||||
", metadata=" + metadata +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user