페이징 유틸 추가
This commit is contained in:
parent
cc5e87af0c
commit
6437f0e721
@ -96,6 +96,9 @@ dependencies {
|
|||||||
/** mariaDB */
|
/** mariaDB */
|
||||||
implementation "org.mariadb.jdbc:mariadb-java-client:${mariadbClientVersion}"
|
implementation "org.mariadb.jdbc:mariadb-java-client:${mariadbClientVersion}"
|
||||||
|
|
||||||
|
/** pageHelper */
|
||||||
|
implementation "com.github.pagehelper:pagehelper-spring-boot-starter:${pageHelperVersion}"
|
||||||
|
|
||||||
/** mybatis-spring-boot-starter */
|
/** mybatis-spring-boot-starter */
|
||||||
implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootVersion}"
|
implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter:${mybatisSpringBootVersion}"
|
||||||
|
|
||||||
|
|||||||
@ -18,3 +18,4 @@ lombokVersion=1.18.34
|
|||||||
mybatisSpringBootVersion=3.0.3
|
mybatisSpringBootVersion=3.0.3
|
||||||
jsonVersion = 20240303
|
jsonVersion = 20240303
|
||||||
mariadbClientVersion = 3.4.1
|
mariadbClientVersion = 3.4.1
|
||||||
|
pageHelperVersion = 1.4.7
|
||||||
50
src/main/java/io/company/localhost/utils/PageUtil.java
Normal file
50
src/main/java/io/company/localhost/utils/PageUtil.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package io.company.localhost.utils;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PageUtil {
|
||||||
|
|
||||||
|
|
||||||
|
public static PageInfo<Map<String , Object>> redefineNavigation(PageInfo<Map<String , Object>> list){
|
||||||
|
|
||||||
|
// 페이지 배열
|
||||||
|
int[] nav = list.getNavigatepageNums();
|
||||||
|
// 몇 페이지
|
||||||
|
int navigatePages = list.getNavigatePages();
|
||||||
|
// 현재 페이지
|
||||||
|
int currentPage = list.getPageNum();
|
||||||
|
// 총 페이지 수
|
||||||
|
int total = list.getPages();
|
||||||
|
// 배열 길이
|
||||||
|
int navLength = nav.length;
|
||||||
|
|
||||||
|
if(navLength != 0){
|
||||||
|
int ff = (int) Math.ceil((double) nav[navLength -1] / navigatePages);
|
||||||
|
|
||||||
|
int gg = ff * navigatePages;
|
||||||
|
|
||||||
|
if(gg - currentPage >= navigatePages){
|
||||||
|
gg = gg - navigatePages;
|
||||||
|
}else if(gg == 0){
|
||||||
|
gg = navigatePages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gg > total && total >= navigatePages ){
|
||||||
|
navLength = total%navigatePages;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] nav2 = new int[navLength];
|
||||||
|
gg = gg - (navigatePages - 1);
|
||||||
|
for(int i = 0 ; i < nav2.length ; i++){
|
||||||
|
nav2[i] = gg++;
|
||||||
|
}
|
||||||
|
list.setNavigatepageNums(nav2);
|
||||||
|
list.setNavigateFirstPage(nav2[0]);
|
||||||
|
list.setNavigateLastPage(nav2[nav2.length -1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user