import { Inject } from '@nestjs/common';
import { type IQueryHandler, QueryHandler } from '@nestjs/cqrs';
import {
  INDUSTRIAL_PARK_REPOSITORY,
  type IIndustrialParkRepository,
  type IndustrialMarketData,
} from '../../../domain/repositories/industrial-park.repository';
import { IndustrialMarketQuery } from './industrial-market.query';

@QueryHandler(IndustrialMarketQuery)
export class IndustrialMarketHandler implements IQueryHandler<IndustrialMarketQuery> {
  constructor(
    @Inject(INDUSTRIAL_PARK_REPOSITORY)
    private readonly repo: IIndustrialParkRepository,
  ) {}

  async execute(_query: IndustrialMarketQuery): Promise<IndustrialMarketData> {
    return this.repo.getMarketData();
  }
}
