分页相关封装

This commit is contained in:
tianliyong 2022-10-24 19:52:53 +08:00
parent bb090ffd40
commit 10a1978785
7 changed files with 39 additions and 31 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# 整体介绍

1
RELEASE.md Normal file
View File

@ -0,0 +1 @@
# 版本发布

View File

@ -87,5 +87,15 @@
<artifactId>swagger-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -5,7 +5,9 @@ import cn.axzo.framework.domain.page.PageImpl;
import cn.axzo.framework.domain.page.PageVerbose;
import cn.axzo.framework.domain.page.Pageable;
import cn.axzo.framework.domain.web.code.IRespCode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -69,14 +71,18 @@ public class ApiPageResult<E> extends ApiCoreResult<List<E>> {
return ok(data, page.getTotal(), pageNum, pageSize, verbose);
}
// public static <E> ApiPageResult ok(PageInfo<E> pageInfo) {
// return ok(pageInfo.getList(), pageInfo.getTotal(), pageInfo.getPageNum(), pageInfo.getPageSize());
// }
public static <E> ApiPageResult ok(PageInfo<E> pageInfo) {
return ok(pageInfo.getList(), pageInfo.getTotal(), pageInfo.getPageNum(), pageInfo.getPageSize());
}
public static <E> ApiPageResult<E> ok(org.springframework.data.domain.Page<E> page) {
return ok(page.getContent(), page.getTotalElements());
}
public static <E> ApiPageResult<E> ok(IPage<E> page) {
return ok(page.getRecords(), page.getTotal(), (int)page.getCurrent(), (int)page.getSize());
}
public static <E> ApiPageResult<E> ok(List<E> data, Long total) {
return build(total, SUCCESS.getRespCode(), SUCCESS.getMessage(), data,
null, null, null);

View File

@ -36,7 +36,13 @@
<!-- mybatis的分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<artifactId>pagehelper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -1,5 +1,6 @@
package cn.axzo.framework.web.http;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import cn.axzo.framework.core.net.Nets;
import cn.axzo.framework.domain.page.Page;
@ -60,6 +61,10 @@ public class ApiPageEntity<E> extends ApiCoreEntity<List<E>, ApiPageResult<E>> {
// return status(HttpStatus.OK).ok(pageInfo);
// }
public static <E> ApiPageEntity<E> ok(IPage<E> page) {
return status(HttpStatus.OK).ok(page);
}
public static ApiPageEntityBuilder status(@Nonnull HttpStatus status) {
Assert.notNull(status, "HttpStatus must not be null");
return new ApiPageEntityBuilder(status);
@ -137,9 +142,12 @@ public class ApiPageEntity<E> extends ApiCoreEntity<List<E>, ApiPageResult<E>> {
return wrapper(ApiPageResult.ok(page));
}
// public <E> ApiPageEntity<E> ok(PageInfo<E> pageInfo) {
// return wrapper(ApiPageResult.ok(pageInfo));
// }
public <E> ApiPageEntity<E> ok(PageInfo<E> pageInfo) {
return wrapper(ApiPageResult.ok(pageInfo));
}
public <E> ApiPageEntity<E> ok(IPage<E> page) {
return wrapper(ApiPageResult.ok(page));
}
public <E> ApiPageEntity<E> ok(List<E> data, Long total) {
return wrapper(ApiPageResult.ok(data, total));

24
pom.xml
View File

@ -64,28 +64,4 @@
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<!--nexus下载设置-->
<profile>
<id>nexus</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>my-nexus-repository</name>
<url>https://nexus.axzo.cn/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>my-nexus-repository</name>
<url>https://nexus.axzo.cn/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>