mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-05 01:29:08 +00:00
preparing info param
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
import { InputsService } from './inputs.service';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { Info } from 'src/clients/inputs/interfaces';
|
||||
|
||||
@Controller('inputs')
|
||||
export class InputsController {
|
||||
@@ -41,23 +42,23 @@ export class InputsController {
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
async findAll(@Payload() body: Info) {
|
||||
console.log(process.env.DEV_URL + `/input`, 'ON FIND ALL ROUTE');
|
||||
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.findAll();
|
||||
const response = await inputService.findAll(body);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
async findOne(@Payload() body, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON FIND ONE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.findOne(id);
|
||||
const response = await inputService.findOne({ id, ...body });
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -65,11 +66,13 @@ export class InputsController {
|
||||
@Put(':id')
|
||||
async update(@Payload() updateInputDto, @Param() params) {
|
||||
const { id } = params;
|
||||
const { info } = updateInputDto;
|
||||
delete updateInputDto.info;
|
||||
|
||||
console.log(process.env.DEV_URL + `/input/${id}`, 'ON UPDATE ROUTE');
|
||||
const inputService = new InputsService(this.inputsClientService);
|
||||
|
||||
const response = await inputService.update(id, updateInputDto);
|
||||
const response = await inputService.update(id, info, updateInputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||
import { InputsClientService } from 'src/clients/inputs/client.service';
|
||||
import { IIdRequest, Info } from 'src/clients/inputs/interfaces';
|
||||
|
||||
@Injectable()
|
||||
export class InputsService {
|
||||
@@ -15,9 +16,9 @@ export class InputsService {
|
||||
}
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
async findAll(info: Info) {
|
||||
try {
|
||||
const findAllInputResponse = await this.inputClient.findAll({});
|
||||
const findAllInputResponse = await this.inputClient.findAll(info);
|
||||
|
||||
return findAllInputResponse;
|
||||
} catch (err) {
|
||||
@@ -25,19 +26,20 @@ export class InputsService {
|
||||
}
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
async findOne(idRequest: IIdRequest) {
|
||||
try {
|
||||
const findOneInputResponse = await this.inputClient.findOne({ id });
|
||||
const findOneInputResponse = await this.inputClient.findOne(idRequest);
|
||||
return findOneInputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id: string, data) {
|
||||
async update(id: string, data, info: Info) {
|
||||
try {
|
||||
const updateInputResponse = await this.inputClient.update({
|
||||
id,
|
||||
info,
|
||||
...data,
|
||||
});
|
||||
|
||||
@@ -47,9 +49,9 @@ export class InputsService {
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
async remove(idRequest: IIdRequest) {
|
||||
try {
|
||||
const removeInputResponse = await this.inputClient.remove({ id });
|
||||
const removeInputResponse = await this.inputClient.remove(idRequest);
|
||||
|
||||
return removeInputResponse;
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user