62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpStatus, Param, ParseFilePipeBuilder, Patch, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
|
|
import { SignalsService } from './signals.service';
|
|
import { SignalCreateDto, SignalUpdateDto } from 'src/_dto/anlagen/signals';
|
|
import { FileInterceptor } from '@nestjs/platform-express';
|
|
import type { Express } from 'express';
|
|
|
|
@Controller('rk2/signals')
|
|
export class SignalsController {
|
|
constructor(private readonly service: SignalsService) { }
|
|
|
|
@Get()
|
|
getAll() {
|
|
return this.service.findAll();
|
|
}
|
|
|
|
@Get(':id')
|
|
getOne(@Param('id') id: string) {
|
|
return this.service.findOne(id);
|
|
}
|
|
|
|
@Get("byComponent/:id")
|
|
getByComponent(@Param('id') id: string) {
|
|
return this.service.findByComponent(id);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: SignalCreateDto) {
|
|
console.log(dto)
|
|
return this.service.create(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(@Param('id') id: string, @Body() dto: SignalUpdateDto) {
|
|
return this.service.update(id, dto);
|
|
}
|
|
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string) {
|
|
return this.service.remove(id);
|
|
}
|
|
|
|
|
|
|
|
@Post('upload')
|
|
@UseInterceptors(FileInterceptor('file'))
|
|
uploadExcel(
|
|
@UploadedFile(
|
|
new ParseFilePipeBuilder().build({
|
|
errorHttpStatusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
|
}),
|
|
)
|
|
file: Express.Multer.File,
|
|
) {
|
|
return {
|
|
message: 'Excel erfolgreich empfangen',
|
|
filename: file.originalname,
|
|
size: file.size,
|
|
};
|
|
}
|
|
}
|