import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { DefaultcreaditlimitService } from './defaultcreaditlimit.service';

@Controller()
export class DefaultcreaditlimitController {
  constructor(private readonly service: DefaultcreaditlimitService) {}

  @MessagePattern({ cmd: 'default_credit_limit_get_all' })
  async getAll() {
    return await this.service.getAll();
  }

  @MessagePattern({ cmd: 'default_credit_limit_get_by_id' })
  async getById(@Payload() data: { id: number }) {
    return await this.service.getById(data.id);
  }

  @MessagePattern({ cmd: 'default_credit_limit_add' })
  async add(@Payload() data: { body: any }) {
    return await this.service.add(data.body);
  }

  @MessagePattern({ cmd: 'default_credit_limit_update' })
  async update(@Payload() data: { id: number; body: any }) {
    return await this.service.update(data.id, data.body);
  }
}
