proteje rotas com JwtAuthGuard e documenta endpoints com Swagger

This commit is contained in:
unknown
2025-03-28 19:46:44 -03:00
parent 36aea127c1
commit 5e4ef04b4a
20 changed files with 372 additions and 66 deletions

View File

@@ -4,48 +4,62 @@
https://docs.nestjs.com/controllers#controllers
*/
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { LogisticService } from './logistic.service';
import { CarOutDelivery } from '../core/models/car-out-delivery.model';
import { CarInDelivery } from '../core/models/car-in-delivery.model';
import {
Body,
Controller,
Get,
Param,
Post,
UseGuards
} from '@nestjs/common';
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard'; // ajuste o caminho se necessário
import { ApiBearerAuth, ApiTags, ApiOperation } from '@nestjs/swagger';
@Controller('api/v1/logistic')
export class LogisticController {
constructor( private readonly logisticService: LogisticService) {}
@ApiTags('Logística')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('api/v1/logistic')
export class LogisticController {
constructor(private readonly logisticService: LogisticService) {}
@Get('expedicao')
@ApiOperation({ summary: 'Retorna informações de expedição' })
getExpedicao() {
try {
return this.logisticService.getExpedicao();
} catch (err) {
console.log(err);
}
return this.logisticService.getExpedicao();
}
@Get('employee')
@ApiOperation({ summary: 'Retorna lista de funcionários' })
getEmployee() {
return this.logisticService.getEmployee();
return this.logisticService.getEmployee();
}
@Get('deliveries/:placa')
@ApiOperation({ summary: 'Retorna entregas por placa' })
getDelivery(@Param('placa') placa: string) {
return this.logisticService.getDeliveries(placa);
return this.logisticService.getDeliveries(placa);
}
@Get('status-car/:placa')
@ApiOperation({ summary: 'Retorna status do veículo por placa' })
getStatusCar(@Param('placa') placa: string) {
return this.logisticService.getStatusCar(placa);
return this.logisticService.getStatusCar(placa);
}
@Post('create')
@ApiOperation({ summary: 'Registra saída de veículo' })
createOutCar(@Body() data: CarOutDelivery) {
return this.logisticService.createCarOut(data);
return this.logisticService.createCarOut(data);
}
@Post('return-car')
@ApiOperation({ summary: 'Registra retorno de veículo' })
createinCar(@Body() data: CarInDelivery) {
return this.logisticService.createCarIn(data);
return this.logisticService.createCarIn(data);
}
}
}