Update Protospack Name and Network Config

This commit is contained in:
Victor Radael
2022-08-02 11:47:13 -03:00
parent 00687dc84e
commit 4e6883a404
19 changed files with 180 additions and 72 deletions
@@ -3,10 +3,12 @@ import {
Controller,
Delete,
Get,
Headers,
Inject,
Param,
Patch,
Post,
Query,
} from '@nestjs/common';
import { NetworkConfigService } from './network-config.service';
import { DadosferaLogger } from 'dadosfera-logs';
@@ -33,12 +35,23 @@ export class NetworkConfigController {
}
@Get()
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findAllNetworkConfigs(@User() user: RequestUser) {
async findAllNetworkConfigs(
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Query() queries,
) {
this.logger.info('GET /network-config', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findAllNetworkConfigs(user.customer_name);
const { user_id, customer_id, customer_name } = user;
const { search, size, page, ...filters } = queries;
return this.networkConfigService.findAllNetworkConfigs({
body: { search, size, page, filters },
info: { user_id, customer_id, customer_name, language },
});
}
@Get(':id')
@@ -54,6 +67,24 @@ export class NetworkConfigController {
return this.networkConfigService.findNetworkConfigById(id);
}
@Get(':id/details')
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
async findNetworkConfigByIdDetails(
@User() user: RequestUser,
@Headers('Dadosfera-Lang') language,
@Param('id') id: string,
) {
this.logger.info('GET /network-config/:id', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.findNetworkConfigByIdDetails(id, {
customer_name: user.customer_name,
customer_id: user.customer_id,
language,
});
}
@Post()
@ApiOkResponse({ type: CreateNetworkConfigRes })
async createNetworkConfigs(
@@ -64,10 +95,10 @@ export class NetworkConfigController {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.createNetworkConfig(
body,
user.customer_name,
);
return this.networkConfigService.createNetworkConfig(body, {
customer_name: user.customer_name,
customer_id: user.customer_id,
});
}
@Patch(':id')
@@ -97,6 +128,9 @@ export class NetworkConfigController {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.deleteNetworkConfig(network_config_id);
return this.networkConfigService.deleteNetworkConfig(network_config_id, {
customer_name: user.customer_name,
customer_id: user.customer_id,
});
}
}