INIT
This commit is contained in:
47
backend/src/mpt/mpt.controller.ts
Normal file
47
backend/src/mpt/mpt.controller.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
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<MptModel>) {
|
||||
return this.mptService.create(data);
|
||||
}
|
||||
|
||||
@Post('bulk')
|
||||
bulkCreate(@Body() data: Partial<MptModel>[]) {
|
||||
return this.mptService.bulkCreate(data);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
update(@Param('id') id: string, @Body() data: Partial<MptModel>) {
|
||||
return this.mptService.update(+id, data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.mptService.remove(+id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user