Skip to content

Commit

Permalink
Merge pull request #5 from PatrickOtero/cleaning/ReportController
Browse files Browse the repository at this point in the history
Cleaning/report controller
  • Loading branch information
PatrickOtero authored Sep 8, 2023
2 parents 2baac9c + 5d54017 commit fd28190
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 97 deletions.
4 changes: 2 additions & 2 deletions src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
ApiTags
} from '@nestjs/swagger';
import { Response } from 'express';
import { LoginSwagger } from 'src/shared/Swagger/Auth/login.swagger';
import { UserLoggedSwagger } from 'src/shared/Swagger/Auth/user-logged.swagger';
import { LoginSwagger } from 'src/shared/Swagger/auth/login.swagger';
import { UserLoggedSwagger } from 'src/shared/Swagger/auth/user-logged.swagger';
import { UsersEntity } from '../../database/entities/users.entity';
import { LoggedUser } from './decorator/logged-user.decorator';
import { UserLoginDto } from './dtos/user-login.dto';
Expand Down
41 changes: 18 additions & 23 deletions src/modules/comment/comment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import {
Post,
Put,
} from '@nestjs/common';
import { ApiExcludeController, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ApiExcludeController, ApiTags } from '@nestjs/swagger';
import { Throttle } from '@nestjs/throttler';
import { CreateCommentSwagger } from 'src/shared/Swagger/comment/create-comment.swagger';
import { DeleteCommentarySwagger } from 'src/shared/Swagger/comment/delete-commentary.swagger';
import { GetAllCommentariesSwagger } from 'src/shared/Swagger/comment/get-all-commentaries.swagger';
import { GetOneCommentaryByIdSwagger } from 'src/shared/Swagger/comment/get-one-commentary.swagger';
import { UpdateCommentarySwagger } from 'src/shared/Swagger/comment/update-commentary.swagger';
import { CommentIdDto } from './dtos/comment-id.dto';
import { CreateCommentDto } from './dtos/create-comment.dto';
import { UpdateCommentDto } from './dtos/update-comment.dto';
Expand All @@ -21,8 +26,8 @@ import {
} from './services';

@ApiExcludeController()
@ApiTags('Comment')
@Controller('comment')
@ApiTags('Commentary')
@Controller('commentary')
export class CommentController {
constructor(
private createCommentService: CreateCommentService,
Expand All @@ -34,45 +39,35 @@ export class CommentController {

@Throttle(2, 30)
@Post()
@ApiOperation({
summary: 'Cadastrar um comentário.',
})
async createComment(@Body() data: CreateCommentDto) {
@CreateCommentSwagger()
async createCommentary(@Body() data: CreateCommentDto) {
return this.createCommentService.execute(data);
}

@Get()
@ApiOperation({
summary: 'Encontrar todos os comentários.',
})
async getAllComments() {
@GetAllCommentariesSwagger()
async getAllCommentaries() {
return this.getAllCommentsService.execute();
}

@Get(':id')
@ApiOperation({
summary: 'Buscar um comentário por id.',
})
async getCommentById(@Param() { id }: CommentIdDto) {
@GetOneCommentaryByIdSwagger()
async getCommentaryById(@Param() { id }: CommentIdDto) {
return this.getCommentByIdService.execute(id);
}

@Put(':id')
@ApiOperation({
summary: 'Atualizar um comentário por id.',
})
async updateComment(
@UpdateCommentarySwagger()
async updateCommentary(
@Param() { id }: CommentIdDto,
@Body() data: UpdateCommentDto,
) {
return this.updateCommentService.execute(id, data);
}

@Delete(':id')
@ApiOperation({
summary: 'Excluir um comentário por id.',
})
async deleteComment(@Param() { id }: CommentIdDto) {
@DeleteCommentarySwagger()
async deleteCommentary(@Param() { id }: CommentIdDto) {
return this.deleteCommentService.execute(id);
}
}
17 changes: 3 additions & 14 deletions src/modules/curriculum/curriculum.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { FileInterceptor } from '@nestjs/platform-express';
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { Response } from 'express';
import { UploadCurriculumSwagger } from 'src/shared/Swagger/curriculum/upload-curriculum.swagger';
import { UsersEntity } from '../../database/entities/users.entity';
import { LoggedUser } from '../auth/decorator/logged-user.decorator';
import { CurriculumService } from './curriculum.service';
Expand All @@ -37,19 +38,7 @@ export class CurriculumController {
return res.status(status).send(data);
}

@ApiConsumes('multipart/form-data')
@ApiBody({
description: 'Upload images',
schema: {
type: 'object',
properties: {
file: {
type: 'string',
format: 'binary',
},
},
},
})
@UploadCurriculumSwagger()
@Post('upload')
@UseInterceptors(FileInterceptor('file'))
async uploadCurriculum(
Expand Down
59 changes: 16 additions & 43 deletions src/modules/jobs/jobs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ import {
Body,
Controller,
Get,
HttpStatus,
NotFoundException,
Param,
Patch,
Post,
Put,
Query,
UseGuards,
UseGuards
} from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import {
ApiBearerAuth,
ApiOperation,
ApiResponse,
ApiTags,
ApiTags
} from '@nestjs/swagger';
import { ArchiveJobSwagger } from 'src/shared/Swagger/jobs/archive-job.swagger';
import { CreateNewJobSwagger } from 'src/shared/Swagger/jobs/create-new-job.swagger';
import { GetOneJobSwagger } from 'src/shared/Swagger/jobs/get-one-job.swagger';
import { SearchJobSwagger } from 'src/shared/Swagger/jobs/search-job.swagger';
import { UpdateJobSwagger } from 'src/shared/Swagger/jobs/update-job.swagger';
import { CompaniesEntity } from '../../database/entities/companies.entity';
import { JobsEntity } from '../../database/entities/jobs.entity';
import { BadRequestSwagger } from '../../shared/Swagger/bad-request.swagger';
import { UnauthorizedSwagger } from '../../shared/Swagger/unauthorized.swagger';
import { PageOptionsDto } from '../../shared/pagination';
import GetEntity from '../../shared/pipes/pipe-entity.pipe';
import { LoggedCompany } from '../auth/decorator/logged-company.decorator';
Expand All @@ -37,6 +38,8 @@ import {
UpdateJobService,
} from './services';
import { SearchJobsService } from './services/search-job.service';
import { GetAllJobsOfLoggedCompanySwagger } from 'src/shared/Swagger/jobs/get-all-jobs-of-logged-company.swagger';
import { GetAllJobsSwagger } from 'src/shared/Swagger/jobs/get-all-jobs-of-logged-company.swagger copy';

@ApiTags('Job')
@Controller('job')
Expand All @@ -52,24 +55,7 @@ export class JobsController {
) {}

@Post()
@ApiResponse({
status: HttpStatus.CREATED,
description: 'Exemplo do retorno de sucesso da rota',
type: 'Vaga publicada com sucesso',
})
@ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: 'Modelo de erro',
type: UnauthorizedSwagger,
})
@ApiResponse({
status: HttpStatus.BAD_REQUEST,
description: 'Modelo de erro',
type: BadRequestSwagger,
})
@ApiOperation({
summary: 'Criar uma vaga!',
})
@CreateNewJobSwagger()
@ApiBearerAuth()
@UseGuards(AuthGuard())
@ApiOperation({
Expand All @@ -83,20 +69,15 @@ export class JobsController {
}

@Get()
@ApiOperation({
summary: 'Buscar todas as vagas.',
})
@GetAllJobsSwagger()
async getAllJobs(
@Query() pageOptionsDto: PageOptionsDto,
@Query() params: GetAllJobsDto,
) {
return this.getAllJobsService.execute(pageOptionsDto, params);
}

@GetAllJobsOfLoggedCompanySwagger()
@Get('all/:id')
@ApiOperation({
summary: 'Buscar todas as vagas da empresa logada.',
})
async getAll(@Param('id') id: string) {
try {
const company = await this.companyRepository.findCompanyById(id);
Expand All @@ -110,25 +91,19 @@ export class JobsController {
}

@Get(':id')
@ApiOperation({
summary: 'Buscar uma vaga pelo id.',
})
@GetOneJobSwagger()
async getOneJob(@Param('id') id: string) {
return this.getOneJobByIdService.execute(id);
}

@Put(':id')
@ApiOperation({
summary: 'Atualizar uma vaga pelo id.',
})
@UpdateJobSwagger()
async updateJob(@Param('id') id: string, @Body() data: UpdateJobDto) {
return this.updateJobService.execute(id, data);
}

@Patch(':id')
@ApiOperation({
summary: 'Excluir uma vaga pelo id.',
})
@ArchiveJobSwagger()
async archivedJob(
@Param('id', new GetEntity(JobsEntity))
job: JobsEntity,
Expand All @@ -138,9 +113,7 @@ export class JobsController {
}

@Post('/search/:keyword')
@ApiOperation({
summary: 'Buscar vaga',
})
@SearchJobSwagger()
async searchJobs(
@Query() pageOptionsDto: PageOptionsDto,
@Body() data: GetAllJobsDto,
Expand Down
25 changes: 10 additions & 15 deletions src/modules/reports/reports.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import {
FindReportByIdService,
UpdateReportService,
} from './services';
import { CreateReportSwagger } from 'src/shared/Swagger/reports/create-report.swagger';
import { GetAllReportsSwagger } from 'src/shared/Swagger/reports/get-all-reports.swagger';
import { GetReportByIdSwagger } from 'src/shared/Swagger/reports/get-report-by-id.swagger';
import { UpdateReportSwagger } from 'src/shared/Swagger/reports/update-report.swagger';
import { DeleteReportSwagger } from 'src/shared/Swagger/reports/delete-report.swagger';

@ApiExcludeController()
@ApiTags('Report')
Expand All @@ -32,33 +37,25 @@ export class ReportsController {
) {}

@Post('')
@ApiOperation({
summary: 'Criar um relatório.',
})
@CreateReportSwagger()
async create(@Body() data: CreateReportDto) {
return this.createReportService.execute(data);
}

@Get()
@ApiOperation({
summary: 'Encontrar todos os relatórios.',
})
@GetAllReportsSwagger()
async getAllReports() {
return this.findAllReportsService.execute();
}

@Get(':id')
@ApiOperation({
summary: 'Encontrar um relatório por id.',
})
@GetReportByIdSwagger()
async getReportById(@Param() data: ReportIdDto) {
return this.findReportByIdService.execute(data);
}

@Put(':id')
@ApiOperation({
summary: 'Atualizar um relatório por id.',
})
@UpdateReportSwagger()
async updateReport(
@Param() reportId: ReportIdDto,
@Body() data: UpdateReportDto,
Expand All @@ -67,9 +64,7 @@ export class ReportsController {
}

@Delete(':id')
@ApiOperation({
summary: 'Excluir um relatório por id.',
})
@DeleteReportSwagger()
async deleteReport(@Param() data: ReportIdDto) {
return this.deleteReportService.execute(data);
}
Expand Down
10 changes: 10 additions & 0 deletions src/shared/Swagger/comment/create-comment.swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { applyDecorators } from "@nestjs/common";
import { ApiOperation } from "@nestjs/swagger";

export function CreateCommentSwagger() {
return applyDecorators(
ApiOperation({
summary: 'Cadastrar um comentário.',
})
)
}
10 changes: 10 additions & 0 deletions src/shared/Swagger/comment/delete-commentary.swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { applyDecorators } from "@nestjs/common";
import { ApiOperation } from "@nestjs/swagger";

export function DeleteCommentarySwagger() {
return applyDecorators(
ApiOperation({
summary: 'Excluir um comentário por id.',
})
)
}
10 changes: 10 additions & 0 deletions src/shared/Swagger/comment/get-all-commentaries.swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { applyDecorators } from "@nestjs/common";
import { ApiOperation } from "@nestjs/swagger";

export function GetAllCommentariesSwagger() {
return applyDecorators(
ApiOperation({
summary: 'Encontrar todos os comentários.',
})
)
}
10 changes: 10 additions & 0 deletions src/shared/Swagger/comment/get-one-commentary.swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { applyDecorators } from "@nestjs/common";
import { ApiOperation } from "@nestjs/swagger";

export function GetOneCommentaryByIdSwagger() {
return applyDecorators(
ApiOperation({
summary: 'Buscar um comentário por id.',
})
)
}
10 changes: 10 additions & 0 deletions src/shared/Swagger/comment/update-commentary.swagger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { applyDecorators } from "@nestjs/common";
import { ApiOperation } from "@nestjs/swagger";

export function UpdateCommentarySwagger() {
return applyDecorators(
ApiOperation({
summary: 'Atualizar um comentário por id.',
})
)
}
Loading

0 comments on commit fd28190

Please sign in to comment.