From e999839bc50e75a37863746a38837ddcaefd05ea Mon Sep 17 00:00:00 2001 From: sdraris Date: Mon, 8 Sep 2025 09:50:30 +0200 Subject: [PATCH] correction for generic users --- src/entities/users.entity.ts | 13 ++++++++-- src/routes/user/dto/create_user.dto.ts | 33 ++++++++++++++++++-------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/entities/users.entity.ts b/src/entities/users.entity.ts index 735f4d5..8b653ee 100644 --- a/src/entities/users.entity.ts +++ b/src/entities/users.entity.ts @@ -42,10 +42,10 @@ export class Users { password_hash: string; @Column({ name: 'prenom', nullable: true }) - first_name: string; + first_name?: string; @Column({ name: 'nom', nullable: true }) - last_name: string; + last_name?: string; @Column({ type: 'enum', @@ -91,6 +91,12 @@ export class Users { @Column({ default: false, name: 'changement_mdp_obligatoire' }) must_change_password: boolean; + @Column({ nullable: true, name: 'ville' }) + city?: string; + + @Column({ nullable: true, name: 'code_postal' }) + postal_code?: string; + @CreateDateColumn({ name: 'cree_le', type: 'timestamptz' }) created_at: Date; @@ -106,4 +112,7 @@ export class Users { @OneToMany(() => Message, m => m.sender) messages?: Message[]; + + @OneToMany(() => Parents, parent => parent.co_parent) + co_parent_in?: Parents[]; } diff --git a/src/routes/user/dto/create_user.dto.ts b/src/routes/user/dto/create_user.dto.ts index fe5d88f..82a6e3d 100644 --- a/src/routes/user/dto/create_user.dto.ts +++ b/src/routes/user/dto/create_user.dto.ts @@ -25,15 +25,15 @@ export class CreateUserDto { @ApiProperty({ example: 'Julien' }) @IsString() - @IsNotEmpty() + @IsOptional() @MaxLength(100) - first_name: string; + first_name?: string; @ApiProperty({ example: 'Dupont' }) @IsString() - @IsNotEmpty() + @IsOptional() @MaxLength(100) - last_name: string; + last_name?: string; @ApiProperty({ enum: GenreType, required: false, default: GenreType.AUTRE }) @IsOptional() @@ -51,14 +51,27 @@ export class CreateUserDto { @ApiProperty({ example: '+33123456789' }) @IsString() - @IsNotEmpty() + @IsOptional() @MaxLength(20) - phone: string; + phone?: string; + + @ApiProperty({ example: 'Paris', required: false }) + @IsOptional() + @IsString() + @MaxLength(150) + city?: string; + + @ApiProperty({ example: '75000', required: false }) + @IsOptional() + @IsString() + @MaxLength(10) + postal_code?: string; + @ApiProperty({ example: '10 rue de la paix, 75000 Paris' }) @IsString() - @IsNotEmpty() - address: string; + @IsOptional() + address?: string; @ApiProperty({ example: 'https://example.com/photo.jpg', required: false }) @IsOptional() @@ -72,8 +85,8 @@ export class CreateUserDto { @ApiProperty({ required: false }) @IsOptional() - @IsDateString() - consent_photo_at?: string; + @IsDateString({}, { message: 'consent_photo_at doit ĂȘtre une date ISO valide' }) + consent_photo_at?: string | null; @ApiProperty({ default: false }) @IsOptional()