import { Controller, Get, Param, Query } from '@nestjs/common';
import { MptService } from './mpt.service';

@Controller('mpt')
export class MptController {
  constructor(private readonly mptService: MptService) {}

  /**
   * MPT 참조값 조회
   */
  @Get('reference')
  getReferenceValues() {
    return this.mptService.getReferenceValues();
  }

  @Get()
  findAll(
    @Query('cowShortNo') cowShortNo?: string,
    @Query('cowId') cowId?: string,
  ) {
    if (cowId) {
      return this.mptService.findByCowId(cowId);
    }
    if (cowShortNo) {
      return this.mptService.findByCowShortNo(cowShortNo);
    }
    return [];
  }

  /**
   * 농장별 MPT 통계 조회
   */
  @Get('statistics/:farmNo')
  getMptStatistics(@Param('farmNo') farmNo: string) {
    return this.mptService.getMptStatistics(+farmNo);
  }
}
