feat(backend): implement Relais module and relation with Gestionnaire (Ticket #94)
- Create Relais entity - Create Relais module, controller, service with CRUD - Update Users entity with ManyToOne relation to Relais - Update GestionnairesService to handle relaisId Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { OmitType } from "@nestjs/swagger";
|
||||
import { ApiProperty, OmitType } from "@nestjs/swagger";
|
||||
import { CreateUserDto } from "./create_user.dto";
|
||||
import { IsOptional, IsUUID } from "class-validator";
|
||||
|
||||
export class CreateGestionnaireDto extends OmitType(CreateUserDto, ['role'] as const) {}
|
||||
export class CreateGestionnaireDto extends OmitType(CreateUserDto, ['role'] as const) {
|
||||
@ApiProperty({ required: false, description: 'ID du relais de rattachement' })
|
||||
@IsOptional()
|
||||
@IsUUID()
|
||||
relaisId?: string;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,24 @@ export class GestionnairesService {
|
||||
: undefined,
|
||||
changement_mdp_obligatoire: dto.changement_mdp_obligatoire ?? false,
|
||||
role: RoleType.GESTIONNAIRE,
|
||||
relaisId: dto.relaisId,
|
||||
});
|
||||
return this.gestionnaireRepository.save(entity);
|
||||
}
|
||||
|
||||
// Liste des gestionnaires
|
||||
async findAll(): Promise<Users[]> {
|
||||
return this.gestionnaireRepository.find({ where: { role: RoleType.GESTIONNAIRE } });
|
||||
return this.gestionnaireRepository.find({
|
||||
where: { role: RoleType.GESTIONNAIRE },
|
||||
relations: ['relais'],
|
||||
});
|
||||
}
|
||||
|
||||
// Récupérer un gestionnaire par ID
|
||||
async findOne(id: string): Promise<Users> {
|
||||
const gestionnaire = await this.gestionnaireRepository.findOne({
|
||||
where: { id, role: RoleType.GESTIONNAIRE },
|
||||
relations: ['relais'],
|
||||
});
|
||||
if (!gestionnaire) throw new NotFoundException('Gestionnaire introuvable');
|
||||
return gestionnaire;
|
||||
|
||||
Reference in New Issue
Block a user