2022-07-01 09:59:39 +00:00
|
|
|
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' })
|
2022-07-01 09:59:39 +00:00
|
|
|
create(@Payload() createNotificationDto: CreateNotificationDto) {
|
|
|
|
return this.notificationsService.create(createNotificationDto);
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'findAllNotifications' })
|
2022-07-01 09:59:39 +00:00
|
|
|
findAll() {
|
|
|
|
return this.notificationsService.findAll();
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'findOneNotification' })
|
2022-07-01 09:59:39 +00:00
|
|
|
findOne(@Payload() id: number) {
|
|
|
|
return this.notificationsService.findOne(id);
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'updateNotification' })
|
2022-07-01 09:59:39 +00:00
|
|
|
update(@Payload() updateNotificationDto: UpdateNotificationDto) {
|
2022-07-25 04:38:48 +00:00
|
|
|
return this.notificationsService.update(
|
|
|
|
updateNotificationDto.id,
|
|
|
|
updateNotificationDto,
|
|
|
|
);
|
2022-07-01 09:59:39 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'removeNotification' })
|
2022-07-01 09:59:39 +00:00
|
|
|
remove(@Payload() id: number) {
|
|
|
|
return this.notificationsService.remove(id);
|
|
|
|
}
|
|
|
|
}
|