Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e402d75610 | ||
|
|
6b2ffd017c | ||
|
|
65ae32dc87 | ||
|
|
4cbb2ba64c | ||
|
|
73e767322b | ||
|
|
2bb29b681c | ||
|
|
24c508187b | ||
|
|
670a8c5b46 | ||
|
|
43607842e6 | ||
|
|
4c822300c4 | ||
|
|
7ff7dd71a8 | ||
|
|
ca1c11ff18 | ||
|
|
28aa0abcec | ||
|
|
1210016142 | ||
|
|
6cdbe702fc | ||
|
|
ce23a75b8e | ||
|
|
4ae50fca11 | ||
|
|
d615467ee5 | ||
|
|
c948fff21d | ||
|
|
5608459355 | ||
|
|
f240713dc0 |
@@ -55,10 +55,3 @@ pids
|
|||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
|
||||||
# Tests bdd
|
|
||||||
.vscode/
|
|
||||||
BDD.sql
|
|
||||||
migrations/
|
|
||||||
src/seed/
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { ParentsModule } from './routes/parents/parents.module';
|
|||||||
import { AuthModule } from './routes/auth/auth.module';
|
import { AuthModule } from './routes/auth/auth.module';
|
||||||
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
|
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
|
||||||
import { AllExceptionsFilter } from './common/filters/all_exceptions.filters';
|
import { AllExceptionsFilter } from './common/filters/all_exceptions.filters';
|
||||||
|
import { EnfantsModule } from './routes/enfants/enfants.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -46,6 +47,7 @@ import { AllExceptionsFilter } from './common/filters/all_exceptions.filters';
|
|||||||
}),
|
}),
|
||||||
UserModule,
|
UserModule,
|
||||||
ParentsModule,
|
ParentsModule,
|
||||||
|
EnfantsModule,
|
||||||
AuthModule,
|
AuthModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export class AuthGuard implements CanActivate {
|
|||||||
if (isPublic) return true;
|
if (isPublic) return true;
|
||||||
|
|
||||||
const request = context.switchToHttp().getRequest<Request>();
|
const request = context.switchToHttp().getRequest<Request>();
|
||||||
|
if (request.path.startsWith('/api-docs')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const authHeader = request.headers['authorization'] as string | undefined;
|
const authHeader = request.headers['authorization'] as string | undefined;
|
||||||
|
|
||||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||||
@@ -30,7 +33,7 @@ export class AuthGuard implements CanActivate {
|
|||||||
const token = authHeader.split(' ')[1];
|
const token = authHeader.split(' ')[1];
|
||||||
try {
|
try {
|
||||||
const payload = await this.jwtService.verifyAsync(token, {
|
const payload = await this.jwtService.verifyAsync(token, {
|
||||||
secret: this.configService.get<string>('jwt.accessSecret'), // ✅ corrige ici
|
secret: this.configService.get<string>('jwt.accessSecret'),
|
||||||
});
|
});
|
||||||
request.user = payload;
|
request.user = payload;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+3
-1
@@ -43,7 +43,9 @@ async function bootstrap() {
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
const document = SwaggerModule.createDocument(app, config);
|
const document = SwaggerModule.createDocument(app, config, {
|
||||||
|
ignoreGlobalPrefix: true,
|
||||||
|
});
|
||||||
SwaggerModule.setup('api-docs', app, document);
|
SwaggerModule.setup('api-docs', app, document);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,4 +66,16 @@ export class AssistantesMaternellesController {
|
|||||||
update(@Param('id') id: string, @Body() dto: UpdateAssistanteDto): Promise<AssistanteMaternelle> {
|
update(@Param('id') id: string, @Body() dto: UpdateAssistanteDto): Promise<AssistanteMaternelle> {
|
||||||
return this.assistantesMaternellesService.update(id, dto);
|
return this.assistantesMaternellesService.update(id, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Roles(RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE, RoleType.ADMINISTRATEUR)
|
||||||
|
@ApiOperation({ summary: 'Supprimer une nounou' })
|
||||||
|
@ApiResponse({ status: 200, description: 'Nounou supprimée avec succès' })
|
||||||
|
@ApiResponse({ status: 403, description: 'Accès refusé : Réservé aux super_admins, gestionnaires et administrateurs' })
|
||||||
|
@ApiResponse({ status: 404, description: 'Nounou non trouvée' })
|
||||||
|
@ApiParam({ name: 'id', description: "UUID de la nounou" })
|
||||||
|
@Delete(':id')
|
||||||
|
remove(@Param('id') id: string): Promise<{ message: string }>
|
||||||
|
{
|
||||||
|
return this.assistantesMaternellesService.remove(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { AssistantesMaternellesService } from './assistantes_maternelles.service';
|
import { AssistantesMaternellesService } from './assistantes_maternelles.service';
|
||||||
import { AssistantesMaternellesController } from './assistantes_maternelles.controller';
|
import { AssistantesMaternellesController } from './assistantes_maternelles.controller';
|
||||||
|
import { AssistanteMaternelle } from 'src/entities/assistantes_maternelles.entity';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { Users } from 'src/entities/users.entity';
|
||||||
|
import { AuthModule } from '../auth/auth.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
imports: [TypeOrmModule.forFeature([AssistanteMaternelle, Users]),
|
||||||
|
AuthModule
|
||||||
|
],
|
||||||
controllers: [AssistantesMaternellesController],
|
controllers: [AssistantesMaternellesController],
|
||||||
providers: [AssistantesMaternellesService],
|
providers: [AssistantesMaternellesService],
|
||||||
|
exports: [
|
||||||
|
AssistantesMaternellesService,
|
||||||
|
TypeOrmModule,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class AssistantesMaternellesModule { }
|
export class AssistantesMaternellesModule { }
|
||||||
|
|||||||
@@ -71,4 +71,10 @@ export class AssistantesMaternellesService {
|
|||||||
await this.assistantesMaternelleRepository.update(id, dto);
|
await this.assistantesMaternelleRepository.update(id, dto);
|
||||||
return this.findOne(id);
|
return this.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Suppression d’une assistante maternelle
|
||||||
|
async remove(id: string): Promise<{ message: string }> {
|
||||||
|
await this.assistantesMaternelleRepository.delete(id);
|
||||||
|
return { message: 'Assistante maternelle supprimée' };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger";
|
|
||||||
import { GenreType, StatutEnfantType } from "src/entities/children.entity";
|
|
||||||
|
|
||||||
export class EnfantResponseDto {
|
|
||||||
@ApiProperty({ example: 'UUID-enfant' })
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@ApiProperty({ enum: StatutEnfantType })
|
|
||||||
status: StatutEnfantType;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'Georges', required: false })
|
|
||||||
first_name?: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'Dupont', required: false })
|
|
||||||
last_name?: string;
|
|
||||||
|
|
||||||
@ApiProperty({ enum: GenreType, required: false })
|
|
||||||
gender?: GenreType;
|
|
||||||
|
|
||||||
@ApiProperty({ example: '2018-06-24', required: false })
|
|
||||||
birth_date?: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: '2024-12-24', required: false })
|
|
||||||
due_date?: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'https://monimage.com/photo.jpg', required: false })
|
|
||||||
photo_url?: string;
|
|
||||||
|
|
||||||
@ApiProperty({ example: false })
|
|
||||||
consent_photo: boolean;
|
|
||||||
|
|
||||||
@ApiProperty({ example: false })
|
|
||||||
is_multiple: boolean;
|
|
||||||
|
|
||||||
@ApiProperty({ example: 'UUID-parent' })
|
|
||||||
parent_id: string;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -6,8 +6,6 @@ import { Roles } from 'src/common/decorators/roles.decorator';
|
|||||||
import { RoleType } from 'src/entities/users.entity';
|
import { RoleType } from 'src/entities/users.entity';
|
||||||
import { Children } from 'src/entities/children.entity';
|
import { Children } from 'src/entities/children.entity';
|
||||||
import { CreateEnfantsDto } from './dto/create_enfants.dto';
|
import { CreateEnfantsDto } from './dto/create_enfants.dto';
|
||||||
import { EnfantResponseDto } from './dto/enfants_response.dto';
|
|
||||||
import { mapEnfantsToResponseDto, mapEnfantToResponseDto } from './enfants.mapper';
|
|
||||||
|
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@ApiTags('Enfants')
|
@ApiTags('Enfants')
|
||||||
@@ -15,55 +13,43 @@ import { mapEnfantsToResponseDto, mapEnfantToResponseDto } from './enfants.mappe
|
|||||||
@Controller('enfants')
|
@Controller('enfants')
|
||||||
export class EnfantsController {
|
export class EnfantsController {
|
||||||
constructor(private readonly enfantsService: EnfantsService) { }
|
constructor(private readonly enfantsService: EnfantsService) { }
|
||||||
// Inscrire un enfant
|
|
||||||
@Post()
|
@Post()
|
||||||
@ApiOperation({ summary: 'Inscrire un enfant' })
|
@ApiOperation({ summary: 'Inscrire un enfant' })
|
||||||
@ApiResponse({ status: 201, type: EnfantResponseDto, description: 'L\'enfant a été inscrit avec succès.' })
|
@ApiResponse({ status: 201, type: Children, description: 'L\'enfant a été inscrit avec succès.' })
|
||||||
@Roles(RoleType.PARENT, RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE)
|
@Roles(RoleType.PARENT, RoleType.SUPER_ADMIN, RoleType.GESTIONNAIRE)
|
||||||
async create(@Body() dto: CreateEnfantsDto): Promise<EnfantResponseDto> {
|
async create(@Body() dto: CreateEnfantsDto): Promise<Children> {
|
||||||
const enfant = await this.enfantsService.create(dto);
|
return this.enfantsService.create(dto);
|
||||||
|
|
||||||
// Mapper l'entité enfant vers le DTO de réponse
|
|
||||||
return mapEnfantToResponseDto(enfant);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupérer tous les enfants avec leurs liens parents
|
// Récupérer tous les enfants avec leurs liens parents
|
||||||
@ApiOperation({ summary: 'Récupérer tous les enfants avec leurs liens parents' })
|
@ApiOperation({ summary: 'Récupérer tous les enfants avec leurs liens parents' })
|
||||||
@ApiResponse({ status: 200, type: [EnfantResponseDto], description: 'Liste de tous les enfants avec leurs liens parents.' })
|
@ApiResponse({ status: 200, type: [Children], description: 'Liste de tous les enfants avec leurs liens parents.' })
|
||||||
@Get()
|
@Get()
|
||||||
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN)
|
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN)
|
||||||
async findAll(): Promise<EnfantResponseDto[]> {
|
async findAll(): Promise<Children[]> {
|
||||||
const enfants = await this.enfantsService.findAll();
|
return this.enfantsService.findAll();
|
||||||
|
|
||||||
// Mapper les entités enfants vers les DTO de réponse
|
|
||||||
return mapEnfantsToResponseDto(enfants);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupérer un enfant par son ID
|
// Récupérer un enfant par son ID
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@ApiOperation({ summary: 'Récupérer un enfant par son ID' })
|
@ApiOperation({ summary: 'Récupérer un enfant par son ID' })
|
||||||
@ApiResponse({ status: 200, type: EnfantResponseDto, description: 'Détails de l\'enfant avec ses liens parents.' })
|
@ApiResponse({ status: 200, type: Children, description: 'Détails de l\'enfant avec ses liens parents.' })
|
||||||
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN, RoleType.PARENT)
|
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN, RoleType.PARENT)
|
||||||
async findOne(@Param('id', new ParseUUIDPipe()) id: string): Promise<EnfantResponseDto> {
|
async findOne(@Param('id', new ParseUUIDPipe()) id: string): Promise<Children> {
|
||||||
const enfant = await this.enfantsService.findOne(id);
|
return this.enfantsService.findOne(id);
|
||||||
|
|
||||||
// Mapper l'entité enfant vers le DTO de réponse
|
|
||||||
return mapEnfantToResponseDto(enfant);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mettre à jour un enfant
|
// Mettre à jour un enfant
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
@ApiOperation({ summary: 'Mettre à jour un enfant' })
|
@ApiOperation({ summary: 'Mettre à jour un enfant' })
|
||||||
@ApiResponse({ status: 200, type: EnfantResponseDto, description: 'L\'enfant a été mis à jour avec succès.' })
|
@ApiResponse({ status: 200, type: Children, description: 'L\'enfant a été mis à jour avec succès.' })
|
||||||
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN)
|
@Roles(RoleType.GESTIONNAIRE, RoleType.SUPER_ADMIN)
|
||||||
async update(
|
async update(
|
||||||
@Param('id', new ParseUUIDPipe()) id: string,
|
@Param('id', new ParseUUIDPipe()) id: string,
|
||||||
@Body() dto: Partial<CreateEnfantsDto>,
|
@Body() dto: Partial<CreateEnfantsDto>,
|
||||||
): Promise<EnfantResponseDto> {
|
): Promise<Children> {
|
||||||
const enfant = await this.enfantsService.update(id, dto);
|
return this.enfantsService.update(id, dto);
|
||||||
|
|
||||||
// Mapper l'entité enfant vers le DTO de réponse
|
|
||||||
return mapEnfantToResponseDto(enfant);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supprimer un enfant
|
// Supprimer un enfant
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
import { Children } from "src/entities/children.entity";
|
|
||||||
import { EnfantResponseDto } from "./dto/enfants_response.dto";
|
|
||||||
|
|
||||||
// Fonction pour mapper une entité Children vers EnfantResponseDto
|
|
||||||
export function mapEnfantToResponseDto(enfant: Children): EnfantResponseDto {
|
|
||||||
return {
|
|
||||||
id: enfant.id,
|
|
||||||
status: enfant.status,
|
|
||||||
first_name: enfant.first_name,
|
|
||||||
last_name: enfant.last_name,
|
|
||||||
gender: enfant.gender,
|
|
||||||
birth_date: enfant.birth_date?.toISOString(),
|
|
||||||
due_date: enfant.due_date?.toISOString(),
|
|
||||||
photo_url: enfant.photo_url,
|
|
||||||
consent_photo: enfant.consent_photo,
|
|
||||||
is_multiple: enfant.is_multiple,
|
|
||||||
parent_id: enfant.parentLinks?.[0]?.parentId ?? null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function mapEnfantsToResponseDto(enfants: Children[]): EnfantResponseDto[] {
|
|
||||||
return enfants.map(mapEnfantToResponseDto);
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -3,10 +3,17 @@ import { EnfantsController } from './enfants.controller';
|
|||||||
import { EnfantsService } from './enfants.service';
|
import { EnfantsService } from './enfants.service';
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { Children } from 'src/entities/children.entity';
|
import { Children } from 'src/entities/children.entity';
|
||||||
|
import { ParentsModule } from '../parents/parents.module';
|
||||||
|
import { ParentsChildren } from 'src/entities/parents_children.entity';
|
||||||
|
import { Parents } from 'src/entities/parents.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Children])],
|
imports: [
|
||||||
|
TypeOrmModule.forFeature([Children, ParentsChildren, Parents]),
|
||||||
|
ParentsModule,
|
||||||
|
],
|
||||||
controllers: [EnfantsController],
|
controllers: [EnfantsController],
|
||||||
providers: [EnfantsService],
|
providers: [EnfantsService],
|
||||||
|
exports: [EnfantsService],
|
||||||
})
|
})
|
||||||
export class EnfantsModule {}
|
export class EnfantsModule {}
|
||||||
|
|||||||
@@ -9,5 +9,8 @@ import { Users } from 'src/entities/users.entity';
|
|||||||
imports: [TypeOrmModule.forFeature([Parents, Users])],
|
imports: [TypeOrmModule.forFeature([Parents, Users])],
|
||||||
controllers: [ParentsController],
|
controllers: [ParentsController],
|
||||||
providers: [ParentsService],
|
providers: [ParentsService],
|
||||||
|
exports: [ParentsService,
|
||||||
|
TypeOrmModule,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class ParentsModule { }
|
export class ParentsModule { }
|
||||||
@@ -5,10 +5,21 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
|||||||
import { Users } from 'src/entities/users.entity';
|
import { Users } from 'src/entities/users.entity';
|
||||||
import { AuthModule } from '../auth/auth.module';
|
import { AuthModule } from '../auth/auth.module';
|
||||||
import { Validation } from 'src/entities/validations.entity';
|
import { Validation } from 'src/entities/validations.entity';
|
||||||
|
import { ParentsModule } from '../parents/parents.module';
|
||||||
|
import { AssistanteMaternelle } from 'src/entities/assistantes_maternelles.entity';
|
||||||
|
import { AssistantesMaternellesModule } from '../assistantes_maternelles/assistantes_maternelles.module';
|
||||||
|
import { Parents } from 'src/entities/parents.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([Users, Validation]),
|
imports: [TypeOrmModule.forFeature(
|
||||||
forwardRef(() => AuthModule),
|
[
|
||||||
|
Users,
|
||||||
|
Validation,
|
||||||
|
Parents,
|
||||||
|
AssistanteMaternelle,
|
||||||
|
]), forwardRef(() => AuthModule),
|
||||||
|
ParentsModule,
|
||||||
|
AssistantesMaternellesModule,
|
||||||
],
|
],
|
||||||
controllers: [UserController],
|
controllers: [UserController],
|
||||||
providers: [UserService],
|
providers: [UserService],
|
||||||
|
|||||||
Reference in New Issue
Block a user