FEAT: add controller method interfaces

This commit is contained in:
Colombo
2023-04-11 20:39:47 -03:00
parent eb1e248d4b
commit bf5b3484a1
3 changed files with 60 additions and 10 deletions
+39 -4
View File
@@ -4710,10 +4710,7 @@
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object"
}
"$ref": "#/components/schemas/CustomerLinksResponse"
}
}
}
@@ -4734,6 +4731,16 @@
"put": {
"operationId": "CustomersController_setCustomerLinks",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerDto"
}
}
}
},
"responses": {
"200": {
"description": "",
@@ -7455,6 +7462,34 @@
"content",
"tags"
]
},
"CustomerLinksResponse": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"links"
]
},
"CustomerDto": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"links"
]
}
}
}
@@ -1,5 +1,5 @@
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { IdResponse } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import {
Body,
Controller,
@@ -18,6 +18,7 @@ import {
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { CustomersService } from './customers.service';
import { CustomerDto, CustomerLinksResponse } from './dtos/customers';
@ApiInternalOnlyController()
@ApiTags('Customers')
@@ -37,16 +38,18 @@ export class CustomersController {
@Get(':id/links')
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
getCustomerLinks(@Param() params): Promise<Link[]> {
const { id } = params;
async getCustomerLinks(@Param('id') id): Promise<CustomerLinksResponse> {
this.logger.info('getCustomerLinks', { id });
return this.customersService.getLinks(id);
const links = await this.customersService.getLinks(id);
return { links };
}
@Put(':id/links')
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
setCustomerLinks(@Body() body, @Param() params) {
const { id } = params;
setCustomerLinks(
@Body() body: CustomerDto,
@Param('id') id,
): Promise<IdResponse> {
const { links } = body;
this.logger.info('setCustomerLinks', { id, links });
return this.customersService.setLinks(id, links);
+12
View File
@@ -0,0 +1,12 @@
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { ApiProperty } from '@nestjs/swagger';
export class CustomerDto {
@ApiProperty()
links: Link[];
}
export class CustomerLinksResponse {
@ApiProperty()
links: Link[];
}