import { BadRequestException , Body , Controller , Get , Param , Patch , Post , Query , } from '@nestjs/common' ; import { CreateNotificationInput } from '../model/create-notification.input' ; import { UpdateNotificationInput } from '../model/update-notification.input' ; import { NotificationService } from '../service/notification.service' ; @ Controller ( 'notification' ) export class NotificationController { constructor ( private readonly notificationService ) { } @ Post ( ) create ( @ Body ( ) body ) { return this . notificationService . create ( body ) ; } @ Patch ( ':id' ) update ( @ Param ( 'id' ) id , @ Body ( ) body ) { return this . notificationService . update ( { id } , body ) ; } @ Get ( ':id' ) findOne ( @ Param ( 'id' ) id ) { return this . notificationService . findOne ( { id } ) ; } @ Get ( ) find ( @ Query ( ) { userId , targetId } ) { if ( userId && ! targetId ) { return this . notificationService . findByUserId ( userId ) ; } if ( targetId && ! userId ) { return this . notificationService . findByTargetId ( targetId ) ; } throw new BadRequestException ( ) ; } }