katoikia-app/servicio-notificaciones/src/notifications/notifications.controller.ts

39 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { NotificationsService } from './notifications.service';
import { CreateNotificationDto } from './dto/create-notification.dto';
import { UpdateNotificationDto } from './dto/update-notification.dto';
@Controller()
export class NotificationsController {
constructor(private readonly notificationsService: NotificationsService) {}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'createNotification' })
create(@Payload() createNotificationDto: CreateNotificationDto) {
return this.notificationsService.create(createNotificationDto);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'findAllNotifications' })
findAll() {
return this.notificationsService.findAll();
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'findOneNotification' })
findOne(@Payload() id: number) {
return this.notificationsService.findOne(id);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'updateNotification' })
update(@Payload() updateNotificationDto: UpdateNotificationDto) {
2022-07-25 04:38:48 +00:00
return this.notificationsService.update(
updateNotificationDto.id,
updateNotificationDto,
);
}
2022-07-25 04:38:48 +00:00
@MessagePattern({ cmd: 'removeNotification' })
remove(@Payload() id: number) {
return this.notificationsService.remove(id);
}
}