Skip to content

Commit

Permalink
feat(fga-eps-mds/2024.2-ARANDU-DOC#95): add start point swagger specs
Browse files Browse the repository at this point in the history
Co-authored-by: dartmol203 <[email protected]>
  • Loading branch information
gabrielm2q and dartmol203 committed Dec 8, 2024
1 parent 2b77e82 commit 88ffeb9
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/journey/dtos/create-journey.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CreateJourneyDto {
description: string;

@ApiProperty({
example: 'id-do-point',
example: 'id-do-start-point',
required: false
})
@IsOptional()
Expand Down
19 changes: 18 additions & 1 deletion src/start_point/dtos/create-start-point.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import { IsString, IsOptional, IsMongoId } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { IsMongoId, IsOptional, IsString } from 'class-validator';

export class CreateStartPointDto {
@ApiProperty({
example: 'Nome',
required: true
})
@IsString()
name: string;

@ApiProperty({
example: 'Descrição',
required: true
})
@IsString()
description: string;

@ApiProperty({
example: 'id-do-user',
required: false
})
@IsOptional()
@IsMongoId()
user?: string;

@ApiProperty({
example: '1',
required: false
})
order?: Number;
}
12 changes: 12 additions & 0 deletions src/start_point/dtos/manageStartPointJourney.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsMongoId, IsNotEmpty } from 'class-validator';

export class ManageStartPointJourneyDTO {
@ApiProperty({
example: 'id-da-jornada',
required: true
})
@IsMongoId()
@IsNotEmpty()
journeyId: string;
}
28 changes: 21 additions & 7 deletions src/start_point/point.controller.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import {
Body,
Controller,
Delete,
Get,
Post,
Body,
NotFoundException,
Param,
Patch,
Post,
Put,
Req,
UnauthorizedException,
Delete,
Patch,
NotFoundException,
} from '@nestjs/common';
import { PointService } from './point.service';
import { ApiBody } from '@nestjs/swagger';
import { Request } from 'express';
import { CreateStartPointDto } from './dtos/create-start-point.dto';
import { ManageStartPointJourneyDTO } from './dtos/manageStartPointJourney.dto';
import { UpdatePointOrderDto } from './dtos/update-point.dto';
import { PointService } from './point.service';

@Controller('points')
export class PointController {
constructor(private readonly pointService: PointService) {}

@ApiBody({
type: CreateStartPointDto,
})
@Post()
async create(
@Body() createStartPointDto: CreateStartPointDto,
Expand Down Expand Up @@ -50,6 +55,9 @@ export class PointController {
return this.pointService.findById(id);
}

@ApiBody({
type: CreateStartPointDto,
})
@Put(':id')
async update(
@Param('id') id: string,
Expand All @@ -63,10 +71,13 @@ export class PointController {
return this.pointService.delete(id);
}

@ApiBody({
type: ManageStartPointJourneyDTO,
})
@Patch(':id/add-journey')
async addJourneyToPoint(
@Param('id') id: string,
@Body() body: { journeyId: string },
@Body() body: ManageStartPointJourneyDTO,
) {
return this.pointService.addJourneyToPoint(id, body.journeyId);
}
Expand All @@ -83,6 +94,9 @@ export class PointController {
}
}

@ApiBody({
type: UpdatePointOrderDto,
})
@Patch('/update-point-order')
async updatePointOrder(
@Body()
Expand Down

0 comments on commit 88ffeb9

Please sign in to comment.