feat(#131): back placement AM↔enfant + BDD garde/sans_garde
- 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>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
CreateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { AssistanteMaternelle } from './assistantes_maternelles.entity';
|
||||
import { Children } from './children.entity';
|
||||
import { Users } from './users.entity';
|
||||
|
||||
@Entity('enfants_assistantes_maternelles', { schema: 'public' })
|
||||
export class AmChildren {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ name: 'id_am', type: 'uuid' })
|
||||
amId: string;
|
||||
|
||||
@Column({ name: 'id_enfant', type: 'uuid' })
|
||||
enfantId: string;
|
||||
|
||||
@Column({ name: 'date_debut', type: 'date' })
|
||||
date_debut: Date;
|
||||
|
||||
@Column({ name: 'date_fin', type: 'date', nullable: true })
|
||||
date_fin?: Date;
|
||||
|
||||
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||
cree_le: Date;
|
||||
|
||||
@Column({ name: 'cree_par', type: 'uuid', nullable: true })
|
||||
cree_par?: string;
|
||||
|
||||
@ManyToOne(() => AssistanteMaternelle, (am) => am.amChildren, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'id_am', referencedColumnName: 'user_id' })
|
||||
am: AssistanteMaternelle;
|
||||
|
||||
@ManyToOne(() => Children, (c) => c.amLinks, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
||||
child: Children;
|
||||
|
||||
@ManyToOne(() => Users, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'cree_par', referencedColumnName: 'id' })
|
||||
createdBy?: Users;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Entity, PrimaryColumn, Column, OneToOne, JoinColumn } from 'typeorm';
|
||||
import { Entity, PrimaryColumn, Column, OneToOne, OneToMany, JoinColumn } from 'typeorm';
|
||||
import { Users } from './users.entity';
|
||||
import { AmChildren } from './am_children.entity';
|
||||
|
||||
@Entity('assistantes_maternelles')
|
||||
export class AssistanteMaternelle {
|
||||
@@ -51,4 +52,7 @@ export class AssistanteMaternelle {
|
||||
/** Numéro de dossier (format AAAA-NNNNNN), même valeur que sur utilisateurs (ticket #103) */
|
||||
@Column({ name: 'numero_dossier', length: 20, nullable: true })
|
||||
numero_dossier?: string;
|
||||
|
||||
@OneToMany(() => AmChildren, (ac) => ac.am)
|
||||
amChildren: AmChildren[];
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import {
|
||||
} 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',
|
||||
ACTIF = 'actif',
|
||||
SCOLARISE = 'scolarise',
|
||||
GARDE = 'garde',
|
||||
SANS_GARDE = 'sans_garde',
|
||||
}
|
||||
|
||||
export enum GenreType {
|
||||
@@ -68,6 +70,9 @@ export class Children {
|
||||
@OneToMany(() => ParentsChildren, pc => pc.child)
|
||||
parentLinks: ParentsChildren[];
|
||||
|
||||
@OneToMany(() => AmChildren, (ac) => ac.child)
|
||||
amLinks: AmChildren[];
|
||||
|
||||
// Relation avec Dossier
|
||||
@OneToMany(() => Dossier, d => d.child)
|
||||
dossiers: Dossier[];
|
||||
|
||||
Reference in New Issue
Block a user