mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-03 21:24:49 +00:00
101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
Param,
|
|
Post,
|
|
Put,
|
|
} from '@nestjs/common';
|
|
import { InputsService } from './inputs.service';
|
|
import { InputsClientService } from 'src/clients/inputs/client.service';
|
|
import { UpdateInputRequest } from 'src/clients/inputs/interfaces';
|
|
import { InputNewCreateRequest } from '@victorradael/protospack';
|
|
|
|
@Controller('inputs')
|
|
export class InputsController {
|
|
constructor(private inputsClientService: InputsClientService) {}
|
|
|
|
@Post('/test-connection')
|
|
async testConnection(@Body() data) {
|
|
console.log(`/test-connection`, 'ON TEST CONNECTION ROUTE');
|
|
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
const response = await inputService.testConnection(data);
|
|
|
|
return response;
|
|
}
|
|
|
|
@Post('/test-connection/get-columns')
|
|
async getColumns(@Body() data) {
|
|
console.log(
|
|
`/test-connection/get-columns`,
|
|
'ON TEST CONNECTION GET COLUMNS ROUTE',
|
|
);
|
|
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
const response = await inputService.getColumns(data);
|
|
|
|
return response;
|
|
}
|
|
|
|
@Post()
|
|
async create(@Body() createInputDto: InputNewCreateRequest) {
|
|
console.log(`/input`, 'ON CREATE ROUTE');
|
|
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
const response = await inputService.create(createInputDto);
|
|
|
|
return response;
|
|
}
|
|
|
|
@Get()
|
|
async findAll(@Body() body) {
|
|
console.log(`/input`, 'ON FIND ALL ROUTE');
|
|
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
|
|
const response = await inputService.findAll(body);
|
|
|
|
return response;
|
|
}
|
|
|
|
@Get('/:id')
|
|
async findOne(@Body() body, @Param() params) {
|
|
const { id } = params;
|
|
console.log(`/input/${id}`, 'ON FIND ONE ROUTE');
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
|
|
const response = await inputService.findOne({ id, ...body });
|
|
|
|
return response;
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) {
|
|
const { id } = params;
|
|
const { info } = updateInputDto;
|
|
delete updateInputDto.info;
|
|
|
|
console.log(`/input/${id}`, 'ON UPDATE ROUTE');
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
|
|
const response = await inputService.update(id, updateInputDto, info);
|
|
|
|
return response;
|
|
}
|
|
|
|
@Delete(':id')
|
|
async delete(@Body() data, @Param() params) {
|
|
const { id } = params;
|
|
|
|
console.log(`/input/${id}`, 'ON DELETE ROUTE');
|
|
|
|
const inputService = new InputsService(this.inputsClientService);
|
|
|
|
const response = await inputService.remove({ id, ...data });
|
|
|
|
return response;
|
|
}
|
|
}
|