diff --git a/bubble-core/src/main/java/cn/fxbin/bubble/core/model/PageResult.java b/bubble-core/src/main/java/cn/fxbin/bubble/core/model/PageResult.java index dc99d162..907fee29 100644 --- a/bubble-core/src/main/java/cn/fxbin/bubble/core/model/PageResult.java +++ b/bubble-core/src/main/java/cn/fxbin/bubble/core/model/PageResult.java @@ -2,9 +2,13 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; import java.io.Serializable; import java.util.List; +import java.util.function.Function; + +import static java.util.stream.Collectors.toList; /** * PageResult @@ -13,6 +17,7 @@ * @version v1.0 * @since 2020/9/21 15:12 */ +@Getter @ApiModel("分页结果") public class PageResult implements Serializable { @@ -31,46 +36,26 @@ public class PageResult implements Serializable { @ApiModelProperty(value = "每页条数", required = true) private Long pageSize; - public List getList() { - return list; - } - public PageResult setList(List list) { this.list = list; return this; } - public Long getTotal() { - return total; - } - public PageResult setTotal(Long total) { this.total = total; return this; } - public Long getTotalPage() { - return totalPage; - } - public PageResult setTotalPage(Long totalPage) { this.totalPage = totalPage; return this; } - public Long getPageNo() { - return pageNo; - } - public PageResult setPageNo(Long pageNo) { this.pageNo = pageNo; return this; } - public Long getPageSize() { - return pageSize; - } - public PageResult setPageSize(Long pageSize) { this.pageSize = pageSize; return this; @@ -97,4 +82,11 @@ public PageResult compute(Long pageSize, Long pageNo, Long total) { } return this; } + + @SuppressWarnings("unchecked") + public PageResult convert(Function mapper) { + List collect = this.getList().stream().map(mapper).collect(toList()); + return ((PageResult)this).setList(collect); + } + } diff --git a/bubble-parent/pom.xml b/bubble-parent/pom.xml index 45a4e99d..b6bc48f0 100644 --- a/bubble-parent/pom.xml +++ b/bubble-parent/pom.xml @@ -21,7 +21,6 @@ spring-boot-maven-plugin ${spring-boot.version} - true true true