ing
This commit is contained in:
parent
b4edd5856b
commit
e33f64d199
|
@ -1,11 +1,78 @@
|
|||
export interface Page {
|
||||
content: any;
|
||||
first: boolean;
|
||||
last: boolean;
|
||||
number: number;
|
||||
numberOfElements: number;
|
||||
size: number;
|
||||
sort: any;
|
||||
totalElements: number;
|
||||
totalPages: number;
|
||||
// export interface Page {
|
||||
// content: any;
|
||||
// first: boolean;
|
||||
// last: boolean;
|
||||
// number: number;
|
||||
// numberOfElements: number;
|
||||
// size: number;
|
||||
// sort: any;
|
||||
// totalElements: number;
|
||||
// totalPages: number;
|
||||
// }
|
||||
|
||||
export class Pageable {
|
||||
page: number;
|
||||
size: number;
|
||||
|
||||
public getPageSize(): number {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public getPageNumber(): number {
|
||||
return this.page;
|
||||
}
|
||||
|
||||
public getOffset(): number {
|
||||
return this.page * this.size;
|
||||
}
|
||||
}
|
||||
|
||||
export class Page<T> {
|
||||
content: T[];
|
||||
pageable: Pageable;
|
||||
total: number;
|
||||
|
||||
public getNumber(): number {
|
||||
return this.pageable == null ? 0 : this.pageable.getPageNumber();
|
||||
}
|
||||
|
||||
public getSize(): number {
|
||||
return this.pageable == null ? 0 : this.pageable.getPageSize();
|
||||
}
|
||||
|
||||
public getTotalPages(): number {
|
||||
return this.getSize() == 0 ? 0 : Math.ceil(this.total / this.getSize());
|
||||
}
|
||||
|
||||
public getNumberOfElements(): number {
|
||||
return this.content.length;
|
||||
}
|
||||
|
||||
public getTotalElements(): number {
|
||||
return this.total;
|
||||
}
|
||||
|
||||
public hasPreviousPage(): boolean {
|
||||
return this.getNumber() > 0;
|
||||
}
|
||||
|
||||
public isFirstPage(): boolean {
|
||||
return !this.hasPreviousPage();
|
||||
}
|
||||
|
||||
public hasNextPage(): boolean {
|
||||
return ((this.getNumber() + 1) * this.getSize()) < this.total;
|
||||
}
|
||||
|
||||
public isLastPage(): boolean {
|
||||
return !this.hasNextPage();
|
||||
}
|
||||
|
||||
public getContent(): T[] {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public hasContent(): boolean {
|
||||
return null !== this.content && 0 < this.content.length;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user