import 'reflect-metadata' ; import { Get , QueryParam , Param , JsonController , Res } from 'routing-controllers' ; import { PageService } from '../../services/PageService' ; @ JsonController ( '/pages' ) export class PageController { constructor ( private pageService ) { } api apiGroup apiParam apiParam apiParam apiParam apiSuccessExample apiSampleRequest apiErrorExample @ Get ( '/pagelist' ) public async pageList ( @ QueryParam ( 'limit' ) limit , @ QueryParam ( 'offset' ) offset , @ QueryParam ( 'keyword' ) keyword , @ QueryParam ( 'count' ) count , @ Res ( ) response ) { const select = [ 'pageId' , 'title' , 'content' , 'isActive' , 'metaTagTitle' , 'metaTagContent' , 'metaTagKeyword' ] ; const search = [ { name : 'title' , op : 'like' , value : keyword , } , { name : 'isActive' , op : 'like' , value : 1 , } , ] ; const WhereConditions = [ ] ; const pageList = await this . pageService . list ( limit , offset , select , search , WhereConditions , count ) ; if ( pageList ) { const successResponse = { status : 1 , message : 'Successfully get pages List' , data : pageList , } ; return response . status ( 200 ) . send ( successResponse ) ; } else { const errorResponse = { status : 0 , message : 'unable to list pages' , } ; return response . status ( 400 ) . send ( errorResponse ) ; } } api apiGroup apiSuccessExample apiSampleRequest apiErrorExample @ Get ( '/get_pagedetails/:id' ) public async pageDetails ( @ Param ( 'id' ) id , @ Res ( ) response ) { const page = await this . pageService . findOne ( { where : { pageId : id , } , } ) ; if ( ! page ) { const errorResponse = { status : 0 , message : 'invalid page id' , } ; return response . status ( 400 ) . send ( errorResponse ) ; } const pageDetails = await this . pageService . findOne ( page ) ; if ( pageDetails ) { const successResponse = { status : 1 , message : 'Successfully get page Details' , data : pageDetails , } ; return response . status ( 200 ) . send ( successResponse ) ; } else { const errorResponse = { status : 0 , message : 'unable to get page Details' , } ; return response . status ( 400 ) . send ( errorResponse ) ; } } }