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

@Controller()
export class BlacklistlogController {
  constructor(private readonly blacklistlogService: BlacklistlogService) {}

  @MessagePattern({ cmd: 'blacklist_log_get_all' })
  async getAll() {
    return await this.blacklistlogService.getAll();
  }

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

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

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