import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { BlacklistService } from './blacklist.service';

@Controller()
export class BlacklistController {
  constructor(private readonly blacklistService: BlacklistService) {}

  @MessagePattern({ cmd: 'blacklist_get_all' })
  async getAll() {
    console.log('ohk@');
    return await this.blacklistService.getAll();
  }

  @MessagePattern({ cmd: 'blacklist_get_by_id' })
  async getById(@Payload() data: { id: number }) {
    return await this.blacklistService.getById(data.id);
  }

  @MessagePattern({ cmd: 'blacklist_add' })
  async add(@Payload() data: { body: any }) {
    return await this.blacklistService.add(data.body);
  }

  @MessagePattern({ cmd: 'blacklist_update' })
  async update(@Payload() data: { id: number; body: any }) {
    return await this.blacklistService.update(data.id, data.body);
  }
}
