import { JsonController , Get , Post , Body , CurrentUser , Authorized , Param , Delete , } from 'routing-controllers' ; import { Service } from 'typedi' ; import { InjectRepository } from 'typeorm-typedi-extensions' ; import { Room , User } from '../../entity' ; import { RoomRepository } from '../../repository' ; @ Service ( ) @ JsonController ( '/rooms' ) export class RoomController { @ InjectRepository ( Room ) private roomRepository : RoomRepository ; @ Authorized ( ) @ Get ( ) getList ( @ CurrentUser ( { required : true } ) user ) { return this . roomRepository . getListByUser ( user ) ; } @ Authorized ( ) @ Get ( '/:id' ) get ( @ CurrentUser ( { required : true } ) user , @ Param ( 'id' ) id ) { return this . roomRepository . getByUser ( id , user ) ; } @ Authorized ( ) @ Get ( '/:id/check' ) check ( @ Param ( 'id' ) id ) { return this . roomRepository . check ( id ) ; } @ Authorized ( ) @ Delete ( '/:id' ) delete ( @ CurrentUser ( { required : true } ) user , @ Param ( 'id' ) id ) { return this . roomRepository . deleteByUser ( id , user ) ; } @ Authorized ( ) @ Post ( ) create ( @ CurrentUser ( { required : true } ) user , @ Body ( ) room ) { return this . roomRepository . createWithStory ( user , room ) ; } }