import { BaseEntity } from './base.entity' ; import { Type , Expose as JsonProperty } from 'class-transformer' ; export class Sort { public property : string ; public direction : 'ASC' | 'DESC' | string ; constructor ( sort ) { if ( sort ) { [ this . property , this . direction ] = sort . split ( ',' ) ; } } asOrder ( ) { const order = { } ; order [ this . property ] = this . direction ; return order ; } } export class PageRequest { @ JsonProperty ( ) page = 0 ; @ JsonProperty ( ) size = 20 ; @ Type ( ( ) => Sort ) sort : Sort = new Sort ( 'id,ASC' ) ; constructor ( page , size , sort ) { this . page = + page || this . page ; this . size = + size || this . size ; this . sort = sort ? new Sort ( sort ) : this . sort ; } } export class Page < T extends BaseEntity > { constructor ( public content , public total , public pageable ) { } }