import { Inject } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import {
  TRANSFER_LISTING_REPOSITORY,
  type ITransferListingRepository,
} from '../../../domain/repositories/transfer-listing.repository';
import { GetTransferListingQuery } from './get-transfer-listing.query';

@QueryHandler(GetTransferListingQuery)
export class GetTransferListingHandler implements IQueryHandler<GetTransferListingQuery> {
  constructor(
    @Inject(TRANSFER_LISTING_REPOSITORY)
    private readonly repo: ITransferListingRepository,
  ) {}

  async execute(query: GetTransferListingQuery) {
    return this.repo.findDetailById(query.id);
  }
}
