-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from SkinSightYnov/dev
Dev
- Loading branch information
Showing
22 changed files
with
347 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Ignore the node modules | ||
/node_modules | ||
|
||
# Ignore the build directory | ||
/dist | ||
|
||
# Ignore the coverage directory | ||
/coverage | ||
|
||
# Ignore the prisma migrations | ||
/prisma/migrations | ||
# Ignore the node modules | ||
/node_modules | ||
|
||
# Ignore the build directory | ||
/dist | ||
|
||
# Ignore the coverage directory | ||
/coverage | ||
|
||
# Ignore the prisma migrations | ||
/prisma/migrations |
27 changes: 27 additions & 0 deletions
27
prisma/migrations/20240221222138_modifiy_appointement/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `criticity` on the `Appointment` table. All the data in the column will be lost. | ||
- The `status` column on the `Consultation` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
- A unique constraint covering the columns `[idConsultation]` on the table `Appointment` will be added. If there are existing duplicate values, this will fail. | ||
- Added the required column `idConsultation` to the `Appointment` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- AlterEnum | ||
ALTER TYPE "Role" ADD VALUE 'ADMIN'; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Appointment" DROP COLUMN "criticity", | ||
ADD COLUMN "idConsultation" TEXT NOT NULL; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Consultation" ADD COLUMN "informations" TEXT NOT NULL DEFAULT '', | ||
ADD COLUMN "resultat" TEXT NOT NULL DEFAULT '', | ||
DROP COLUMN "status", | ||
ADD COLUMN "status" "statusConsultation" NOT NULL DEFAULT 'WAITING'; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Appointment_idConsultation_key" ON "Appointment"("idConsultation"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_idConsultation_fkey" FOREIGN KEY ("idConsultation") REFERENCES "Consultation"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
12 changes: 12 additions & 0 deletions
12
prisma/migrations/20240221225021_add_enum_status_appointement/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
Warnings: | ||
- The `status` column on the `Appointment` table would be dropped and recreated. This will lead to data loss if there is data in the column. | ||
*/ | ||
-- CreateEnum | ||
CREATE TYPE "statusAppointment" AS ENUM ('WAITING', 'ACCEPTED', 'CANCELED', 'REFUSED'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "Appointment" DROP COLUMN "status", | ||
ADD COLUMN "status" "statusAppointment" NOT NULL DEFAULT 'WAITING'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { SetMetadata } from '@nestjs/common'; | ||
import { Role } from '@prisma/client'; | ||
|
||
export const HasRole = (...roles: Role[]) => SetMetadata('roles', roles); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; | ||
import { Reflector } from '@nestjs/core'; | ||
import { Role } from '@prisma/client'; | ||
|
||
@Injectable() | ||
export class RolesGuard implements CanActivate { | ||
constructor(private reflector: Reflector) {} | ||
|
||
canActivate(context: ExecutionContext): boolean { | ||
const requireRoles = this.reflector.getAllAndOverride<Role[]>('roles', [ | ||
context.getHandler(), | ||
context.getClass(), | ||
]); | ||
if (!requireRoles) { | ||
return true; | ||
} | ||
|
||
const { user } = context.switchToHttp().getRequest(); | ||
console.log('user', user); | ||
return requireRoles.some((role) => user.role?.includes(role)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Post, | ||
Body, | ||
Patch, | ||
Param, | ||
Delete, | ||
} from '@nestjs/common'; | ||
import { DermatologuesService } from './dermatologues.service'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
|
||
@ApiTags('dermatologues') | ||
@Controller('dermatologues') | ||
export class DermatologuesController { | ||
constructor(private readonly dermatologuesService: DermatologuesService) {} | ||
|
||
@Get() | ||
findAll() { | ||
return this.dermatologuesService.findAll(); | ||
} | ||
|
||
@Get(':id') | ||
findOne(@Param('id') id: string) { | ||
return this.dermatologuesService.findOne(id); | ||
} | ||
|
||
// @Patch(':id') | ||
// update(@Param('id') id: string, @Body() updateDermatologueDto: ) { | ||
// return this.dermatologuesService.update(+id, updateDermatologueDto); | ||
// } | ||
|
||
// @Delete(':id') | ||
// remove(@Param('id') id: string) { | ||
// return this.dermatologuesService.remove(+id); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { DermatologuesService } from './dermatologues.service'; | ||
import { DermatologuesController } from './dermatologues.controller'; | ||
import { PrismaModule } from 'src/prisma/prisma.module'; | ||
|
||
@Module({ | ||
imports: [PrismaModule], | ||
controllers: [DermatologuesController], | ||
providers: [DermatologuesService], | ||
exports: [DermatologuesService], | ||
}) | ||
export class DermatologuesModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PrismaService } from 'src/prisma/prisma.service'; | ||
|
||
@Injectable() | ||
export class DermatologuesService { | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
async findAll() { | ||
return await this.prisma.user.findMany({ | ||
where: { | ||
role: 'DERMATOLOGUE', | ||
}, | ||
}); | ||
} | ||
|
||
findOne(id: string) { | ||
return this.prisma.user.findUnique({ | ||
where: { | ||
id, | ||
role: 'DERMATOLOGUE', | ||
}, | ||
}); | ||
} | ||
|
||
getAppointmentByDermatologueId(dermatologueId: string) { | ||
return this.prisma.appointment.findMany({ | ||
where: { | ||
idDermatologue: dermatologueId, | ||
}, | ||
}); | ||
} | ||
|
||
// changeAppointmentStatus(appointmentId: string, status: statusAppointment) { | ||
// return this.prisma.appointment.update({ | ||
// where: { | ||
// id: appointmentId, | ||
// }, | ||
// data: { | ||
// status: statusAppointment, | ||
// }, | ||
// }); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class CreateDermatologueDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PartialType } from '@nestjs/swagger'; | ||
import { CreateDermatologueDto } from './create-dermatologue.dto'; | ||
|
||
export class UpdateDermatologueDto extends PartialType(CreateDermatologueDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Appointment, User } from '@prisma/client'; | ||
import { Exclude } from 'class-transformer'; | ||
|
||
export class Medecin implements User { | ||
constructor(partial: Partial<Medecin>) { | ||
Object.assign(this, partial); | ||
} | ||
|
||
@ApiProperty() | ||
id: string; | ||
|
||
@ApiProperty() | ||
updatedAt: Date; | ||
|
||
@ApiProperty() | ||
createdAt: Date; | ||
|
||
@ApiProperty() | ||
firstName: string; | ||
|
||
@ApiProperty() | ||
lastName: string; | ||
|
||
@ApiProperty() | ||
role: 'DERMATOLOGUE'; | ||
|
||
@ApiProperty() | ||
email: string; | ||
|
||
@ApiProperty() | ||
sexe: string; | ||
|
||
@Exclude() | ||
password: string; | ||
|
||
@ApiProperty() | ||
rppsNumber: string; | ||
|
||
@ApiProperty() | ||
address: string; | ||
|
||
@ApiProperty() | ||
city: string; | ||
|
||
@ApiProperty() | ||
zipCode: string; | ||
|
||
@ApiProperty() | ||
secuNumber: string; | ||
|
||
@ApiProperty() | ||
appointmentsPatient: Appointment[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.