- API PATCH …/fiche, POST/DELETE …/enfants/:enfantId, GET avec amChildren - Table enfants_assistantes_maternelles (option D, 1 garde active/enfant) - Statuts enfant: garde/sans_garde remplacent actif (inscription → sans_garde) - BDD.sql canonique réécrit; migration pour BDD existantes - Seed test: hash bcrypt corrigé pour mot de passe « password » Co-authored-by: Cursor <cursoragent@cursor.com>
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import {
|
|
Entity, PrimaryGeneratedColumn, Column,
|
|
OneToMany, ManyToMany, CreateDateColumn, JoinTable
|
|
} from 'typeorm';
|
|
import { Parents } from './parents.entity';
|
|
import { ParentsChildren } from './parents_children.entity';
|
|
import { AmChildren } from './am_children.entity';
|
|
import { Dossier } from './dossiers.entity';
|
|
|
|
export enum StatutEnfantType {
|
|
A_NAITRE = 'a_naitre',
|
|
SCOLARISE = 'scolarise',
|
|
GARDE = 'garde',
|
|
SANS_GARDE = 'sans_garde',
|
|
}
|
|
|
|
export enum GenreType {
|
|
H = 'H',
|
|
F = 'F',
|
|
AUTRE = 'Autre',
|
|
}
|
|
|
|
@Entity('enfants')
|
|
export class Children {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: StatutEnfantType,
|
|
enumName: 'statut_enfant_type',
|
|
name: 'statut'
|
|
})
|
|
status: StatutEnfantType;
|
|
|
|
@Column({ name: 'prenom', length: 100, nullable: true })
|
|
first_name?: string;
|
|
|
|
@Column({ name: 'nom', length: 100, nullable: true })
|
|
last_name?: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: GenreType,
|
|
enumName: 'genre_type',
|
|
nullable: true,
|
|
name: 'genre'
|
|
})
|
|
gender?: GenreType;
|
|
|
|
@Column({ type: 'date', nullable: true, name: 'date_naissance' })
|
|
birth_date?: Date;
|
|
|
|
@Column({ type: 'date', nullable: true, name: 'date_prevue_naissance' })
|
|
due_date?: Date;
|
|
|
|
@Column({ nullable: true, name: 'photo_url', type: 'text' })
|
|
photo_url?: string;
|
|
|
|
@Column({ default: false, name: 'consentement_photo', type: 'boolean' })
|
|
consent_photo: boolean;
|
|
|
|
@Column({ type: 'timestamptz', nullable: true, name: 'date_consentement_photo' })
|
|
consent_photo_at?: Date;
|
|
|
|
@Column({ default: false, name: 'est_multiple', type: 'boolean' })
|
|
is_multiple: boolean;
|
|
|
|
// Lien via table de jointure enfants_parents
|
|
@OneToMany(() => ParentsChildren, pc => pc.child)
|
|
parentLinks: ParentsChildren[];
|
|
|
|
@OneToMany(() => AmChildren, (ac) => ac.child)
|
|
amLinks: AmChildren[];
|
|
|
|
// Relation avec Dossier
|
|
@OneToMany(() => Dossier, d => d.child)
|
|
dossiers: Dossier[];
|
|
}
|