import { Controller, Get, Post, Put, Delete, Body, Param, Query } from '@nestjs/common'; import { MptService } from './mpt.service'; import { MptModel } from './entities/mpt.entity'; @Controller('mpt') export class MptController { constructor(private readonly mptService: MptService) {} @Get() findAll( @Query('farmId') farmId?: string, @Query('cowShortNo') cowShortNo?: string, ) { if (farmId) { return this.mptService.findByFarmId(+farmId); } if (cowShortNo) { return this.mptService.findByCowShortNo(cowShortNo); } return this.mptService.findAll(); } @Get(':id') findOne(@Param('id') id: string) { return this.mptService.findOne(+id); } @Post() create(@Body() data: Partial) { return this.mptService.create(data); } @Post('bulk') bulkCreate(@Body() data: Partial[]) { return this.mptService.bulkCreate(data); } @Put(':id') update(@Param('id') id: string, @Body() data: Partial) { return this.mptService.update(+id, data); } @Delete(':id') remove(@Param('id') id: string) { return this.mptService.remove(+id); } }