From bd2c300e0193059b7a7c580e6b893c7bc74380f6 Mon Sep 17 00:00:00 2001 From: luana-v-santos Date: Fri, 6 Oct 2023 08:22:14 -0300 Subject: [PATCH] feat(CC-69): add NestjsCreatePsychologistService extends CreatePsychologistService --- .../adapters/src/controllers/api/api.module.ts | 3 ++- .../create-psychologist/create-psychologist.controller.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/core-rest-api/adapters/src/controllers/api/api.module.ts b/libs/core-rest-api/adapters/src/controllers/api/api.module.ts index b9b2957..33b4911 100644 --- a/libs/core-rest-api/adapters/src/controllers/api/api.module.ts +++ b/libs/core-rest-api/adapters/src/controllers/api/api.module.ts @@ -7,6 +7,7 @@ import { DatabaseRepositoriesModule } from '../../database/repositories/reposito import { envSchema } from '../../env/env'; import { EnvModule } from '../../env/env.module'; import { CreatePsychologistController } from './use-case/create-psychologist/create-psychologist.controller'; +import { NestjsCreatePsychologistService } from './use-case/create-psychologist/nestjs-create-psychologist.service'; @Module({ imports: [DatabaseRepositoriesModule, EnvModule, AuthModule, ConfigModule.forRoot({ @@ -14,6 +15,6 @@ import { CreatePsychologistController } from './use-case/create-psychologist/cre isGlobal: true })], controllers: [CreatePsychologistController], - providers: [PostgreSqlPrismaOrmService, CreatePsychologistService], + providers: [PostgreSqlPrismaOrmService, CreatePsychologistService, NestjsCreatePsychologistService], }) export class ApiModule {} diff --git a/libs/core-rest-api/adapters/src/controllers/api/use-case/create-psychologist/create-psychologist.controller.ts b/libs/core-rest-api/adapters/src/controllers/api/use-case/create-psychologist/create-psychologist.controller.ts index 79c9aa4..1cbae39 100644 --- a/libs/core-rest-api/adapters/src/controllers/api/use-case/create-psychologist/create-psychologist.controller.ts +++ b/libs/core-rest-api/adapters/src/controllers/api/use-case/create-psychologist/create-psychologist.controller.ts @@ -1,14 +1,13 @@ // eslint-disable-next-line @nx/enforce-module-boundaries import { PostgreSqlPrismaOrmService } from '@clinicControl/core-rest-api/adapters/src/database/infra/prisma/prisma.service'; import { CreatePsychologistDto } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist-dto'; -// import { CreatePsychologistService } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.service'; -import { CreatePsychologistService } from '@clinicControl/core-rest-api/core/src/domains/psychologist/use-cases/create-psychologist/create-psychologist.service'; import { GlobalAppHttpException } from '@clinicControl/core-rest-api/core/src/shared/errors/globalAppHttpException'; import { applicationValidateOrReject } from '@clinicControl/core-rest-api/core/src/shared/validators/validate-or-reject'; import { Body, Controller, Post, UseGuards } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { plainToInstance } from 'class-transformer'; import { ApiKeyGuard } from '../../guards/api-key.guard'; +import { NestjsCreatePsychologistService } from './nestjs-create-psychologist.service'; @ApiTags() @Controller({ @@ -17,13 +16,14 @@ import { ApiKeyGuard } from '../../guards/api-key.guard'; export class CreatePsychologistController { constructor( private prisma: PostgreSqlPrismaOrmService, - private createPsychologistService: CreatePsychologistService + private createPsychologistService: NestjsCreatePsychologistService ) {} @Post('create') @UseGuards(ApiKeyGuard) async execute( @Body() createPsychologistDto: CreatePsychologistDto ): Promise { + try { const createPsychologistDtoInstance = plainToInstance( CreatePsychologistDto,