diff --git a/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/PageResponse.java b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/PageResponse.java index 66b70ae..5e0b4e9 100644 --- a/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/PageResponse.java +++ b/service-configuration/src/main/java/com/lanyuanxiaoyao/service/configuration/entity/PageResponse.java @@ -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 { private List data = new ArrayList<>(0); private Long total = 0L; + private Map metadata = new HashMap<>(); public PageResponse() { } @@ -22,10 +25,15 @@ public class PageResponse { } public PageResponse(List data, Long total) { - this.data = data; + this(data); this.total = total; } + public PageResponse(List data, Long total, Map metadata) { + this(data, total); + this.metadata = metadata; + } + public List getData() { return data; } @@ -42,11 +50,25 @@ public class PageResponse { this.total = total; } + public Map getMetadata() { + return metadata; + } + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + public PageResponse withMetadata(String key, Object value) { + this.metadata.put(key, value); + return this; + } + @Override public String toString() { return "PageResponse{" + "data=" + data + ", total=" + total + + ", metadata=" + metadata + '}'; } }