mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-04 20:29:08 +00:00
preparing info param
This commit is contained in:
Generated
+9750
-17
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -30,7 +30,7 @@
|
||||
"@nestjs/microservices": "^8.4.0",
|
||||
"@nestjs/platform-express": "^8.4.0",
|
||||
"@nestjs/swagger": "^5.1.5",
|
||||
"@victorradael/protospack": "^1.3.1",
|
||||
"@victorradael/protospack": "^1.3.3",
|
||||
"axios": "^0.25.0",
|
||||
"dotenv": "^14.2.0",
|
||||
"grpc": "^1.24.11",
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { OnModuleInit, Inject } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { InputService } from '@victorradael/protospack';
|
||||
import { IIdRequest, ITestConnectionRequest } from './interfaces';
|
||||
import {
|
||||
ICreateInputRequest,
|
||||
IIdRequest,
|
||||
ITestConnectionRequest,
|
||||
UpdateInputRequest,
|
||||
} from './interfaces';
|
||||
|
||||
export class InputsClientService implements OnModuleInit {
|
||||
private inputService: InputService;
|
||||
@@ -14,7 +19,7 @@ export class InputsClientService implements OnModuleInit {
|
||||
this.grpcClient.getService<InputService>('InputService');
|
||||
}
|
||||
|
||||
async create(createInputDto) {
|
||||
async create(createInputDto: ICreateInputRequest) {
|
||||
console.log('InputClientService', 'Create');
|
||||
|
||||
const createInputResponse = await new Promise((resolve, reject) => {
|
||||
@@ -42,10 +47,8 @@ export class InputsClientService implements OnModuleInit {
|
||||
async findOne(data: IIdRequest) {
|
||||
console.log('InputClientService', 'FindOne');
|
||||
|
||||
const { id } = data;
|
||||
|
||||
const findOneInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.FindOne({ id }).subscribe({
|
||||
this.inputService.FindOne(data).subscribe({
|
||||
next(x) {
|
||||
resolve(x);
|
||||
},
|
||||
@@ -91,7 +94,7 @@ export class InputsClientService implements OnModuleInit {
|
||||
return findAllInputResponse;
|
||||
}
|
||||
|
||||
async update(updateInputDTO) {
|
||||
async update(updateInputDTO: UpdateInputRequest) {
|
||||
console.log('InputClientService', 'Update');
|
||||
const updateInputResponse = await new Promise((resolve, reject) => {
|
||||
this.inputService.Update(updateInputDTO).subscribe({
|
||||
|
||||
Vendored
+9
-1
@@ -28,24 +28,32 @@ interface Cron {
|
||||
week_days_resourse_value: number;
|
||||
}
|
||||
|
||||
export interface Info {
|
||||
costumer_id: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
export interface ICreateInputRequest {
|
||||
cron: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
info: Info;
|
||||
}
|
||||
export interface IIdRequest {
|
||||
id: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
interface UpdateInputRequest {
|
||||
export interface UpdateInputRequest {
|
||||
id: string;
|
||||
cron: string;
|
||||
name: string;
|
||||
plugin: string;
|
||||
values: Values;
|
||||
operation: string;
|
||||
info: Info;
|
||||
}
|
||||
|
||||
export interface ITestConnectionRequest {
|
||||
|
||||
@@ -19,4 +19,4 @@ export class OutputsClientConfiguration {
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
Redirect,
|
||||
} from '@nestjs/common';
|
||||
import { Payload } from '@nestjs/microservices';
|
||||
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
@@ -14,15 +13,14 @@ import { OutputsService } from './outputs.service';
|
||||
|
||||
@Controller('outputs')
|
||||
export class OutputsController {
|
||||
|
||||
constructor( private outputsClientService:OutputsClientService){}
|
||||
constructor(private outputsClientService: OutputsClientService) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createOutputDto) {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON CREATE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.create(createOutputDto)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.create(createOutputDto);
|
||||
|
||||
return response;
|
||||
}
|
||||
@@ -31,46 +29,41 @@ export class OutputsController {
|
||||
async findAll() {
|
||||
console.log(process.env.DEV_URL + `/output`, 'ON Find All ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findAll()
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.findAll();
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Param() params) {
|
||||
const {id} = params;
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON Find One ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.findOne(id)
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.findOne(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Payload() updateOutputDto,
|
||||
@Param() params,
|
||||
) {
|
||||
const {id} = params;
|
||||
async update(@Payload() updateOutputDto, @Param() params) {
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON UPDATE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.update(id,updateOutputDto)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.update(id, updateOutputDto);
|
||||
|
||||
return response;
|
||||
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param() params) {
|
||||
const {id} = params;
|
||||
const { id } = params;
|
||||
console.log(process.env.DEV_URL + `/output/${id}`, 'ON DELETE ROUTE');
|
||||
|
||||
const outputService = new OutputsService(this.outputsClientService)
|
||||
const response = await outputService.remove(id)
|
||||
const outputService = new OutputsService(this.outputsClientService);
|
||||
const response = await outputService.remove(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -3,67 +3,59 @@ import { OutputsClientService } from 'src/clients/outputs/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class OutputsService {
|
||||
constructor(private outputClient: OutputsClientService) {}
|
||||
|
||||
constructor( private outputClient: OutputsClientService){}
|
||||
async create(createOutputDto) {
|
||||
try {
|
||||
const createOutputResponse = await this.outputClient.create(
|
||||
createOutputDto,
|
||||
);
|
||||
|
||||
async create(createOutputDto){
|
||||
try{
|
||||
const createOutputResponse = await this.outputClient.create(createOutputDto);
|
||||
|
||||
return createOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return createOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneOutputResponse = await this.outputClient.findOne({id});
|
||||
return findOneOutputResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(id: string) {
|
||||
try {
|
||||
const findOneOutputResponse = await this.outputClient.findOne({ id });
|
||||
return findOneOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllOutputResponse = await this.outputClient.findAll();
|
||||
|
||||
return findAllOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return findAllOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
const updateOutputResponse = await this.outputClient.update({
|
||||
id,
|
||||
...data,
|
||||
});
|
||||
|
||||
try{
|
||||
|
||||
const updateOutputResponse = await this.outputClient.update({id,...data});
|
||||
|
||||
return updateOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return updateOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async remove(id: string) {
|
||||
try {
|
||||
const removeOutputResponse = await this.outputClient.remove({ id });
|
||||
|
||||
try{
|
||||
|
||||
const removeOutputResponse = await this.outputClient.remove({id});
|
||||
|
||||
return removeOutputResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return removeOutputResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user