Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save evertonthepaula/dfa9ad0d652da2460ce8277e2c191d57 to your computer and use it in GitHub Desktop.

Select an option

Save evertonthepaula/dfa9ad0d652da2460ce8277e2c191d57 to your computer and use it in GitHub Desktop.
import { CommonPaginationInterface } from "../interfaces/common-pagination.interface";
export class CommonPaginationDTO implements CommonPaginationInterface {
private defaultSort: CommonPaginationInterface['sort'];
sort: CommonPaginationInterface['sort'];
page: CommonPaginationInterface['page'] = 0;
size: CommonPaginationInterface['size'] = 10;
totalItens: CommonPaginationInterface['totalItens'] = 0;
direction: CommonPaginationInterface['direction'] = 'asc';
constructor(
sort: CommonPaginationInterface['sort'],
) {
this.sort = sort;
this.defaultSort = sort;
}
setSort(sort: CommonPaginationInterface['sort']): void {
this.sort = sort;
}
setPage(page: CommonPaginationInterface['page']): void {
this.page = page;
}
setSize(size: CommonPaginationInterface['size']): void {
this.size = size
}
setTotalItens(totalItens: CommonPaginationInterface['totalItens']): void {
this.totalItens = totalItens;
}
setDiretcion(direction: CommonPaginationInterface['direction']): void {
this.direction = direction;
}
clear() {
this.sort = this.defaultSort;
this.page = 0;
this.size = 10;
this.totalItens = 0;
this.direction = 'asc';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment