From 4024c83c387326b57b70f5f64167fd2563c27670 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 9 Jun 2023 14:31:51 +0800 Subject: [PATCH] =?UTF-8?q?feature(cofiguration):=20=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A2=9D=E5=A4=96=E7=9A=84=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/entity/PageResponse.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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 + '}'; } }