forked from Ynov/ptitspas-ynov-back
75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import {
|
|
Entity, PrimaryGeneratedColumn, Column,
|
|
OneToMany, ManyToMany, CreateDateColumn, JoinTable
|
|
} from 'typeorm';
|
|
import { Parents } from './parents.entity';
|
|
import { ParentsChildren } from './parents_children.entity';
|
|
import { Dossier } from './dossiers.entity';
|
|
|
|
export enum StatutEnfantType {
|
|
A_NAITRE = 'a_naitre',
|
|
ACTIF = 'actif',
|
|
SCOLARISE = 'scolarise',
|
|
}
|
|
|
|
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 })
|
|
first_name: string;
|
|
|
|
@Column({ name: 'nom', length: 100 })
|
|
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' })
|
|
birthdate?: Date;
|
|
|
|
@Column({ type: 'date', nullable: true, name: 'date_prevue_naissance' })
|
|
due_date?: Date;
|
|
|
|
@Column({ nullable: true, name: 'photo_url' })
|
|
photo_url?: string;
|
|
|
|
@Column({ default: false, name: 'consentement_photo' })
|
|
consent_photo: boolean;
|
|
|
|
@Column({ type: 'timestamptz', nullable: true, name: 'date_consentement_photo' })
|
|
consent_photo_at?: Date;
|
|
|
|
@Column({ default: false, name: 'est_multiple' })
|
|
is_multiple: boolean;
|
|
|
|
// Lien via table de jointure enfants_parents
|
|
@OneToMany(() => ParentsChildren, pc => pc.child)
|
|
parentLinks: ParentsChildren[];
|
|
|
|
// Relation avec Dossier
|
|
@OneToMany(() => Dossier, d => d.child)
|
|
dossiers: Dossier[];
|
|
}
|