contrats and avenants_contrats added + modification of other entities
This commit is contained in:
parent
b75034739c
commit
250f21c6c2
@ -1,41 +1,42 @@
|
|||||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm";
|
import {
|
||||||
import { Users } from "./user.entity";
|
Entity, PrimaryColumn, Column, OneToOne, JoinColumn
|
||||||
|
} from 'typeorm';
|
||||||
|
import { Users } from './users.entity';
|
||||||
|
|
||||||
@Entity('assistantes_maternelles')
|
@Entity('assistantes_maternelles')
|
||||||
export class AssistanteMaternelle {
|
export class AssistanteMaternelle {
|
||||||
// Declarer les proprietes ici
|
// PK = FK vers utilisateurs.id
|
||||||
@PrimaryColumn('uuid')
|
@PrimaryColumn('uuid', { name: 'id_utilisateur' })
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|
||||||
@OneToOne(() => Users, user => user.assistanteMaternelle, { onDelete: 'CASCADE' })
|
@OneToOne(() => Users, user => user.assistanteMaternelle, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'user_id' })
|
@JoinColumn({ name: 'id_utilisateur', referencedColumnName: 'id' })
|
||||||
user: Users;
|
user: Users;
|
||||||
|
|
||||||
@Column({type: 'varchar'})
|
@Column({ name: 'numero_agrement', length: 50, nullable: true })
|
||||||
approval_number: string;
|
approval_number?: string;
|
||||||
|
|
||||||
@Column({type: 'date'})
|
@Column({ name: 'date_naissance', type: 'date', nullable: true })
|
||||||
birthdate: Date;
|
birthdate?: Date;
|
||||||
|
|
||||||
@Column({type: 'varchar'})
|
@Column({ name: 'ville_naissance', length: 100, nullable: true })
|
||||||
birthplace_city: string;
|
birthplace_city?: string;
|
||||||
|
|
||||||
@Column({type: 'varchar'})
|
@Column({ name: 'pays_naissance', length: 2, nullable: true })
|
||||||
birthplace_country: string;
|
birthplace_country?: string;
|
||||||
|
|
||||||
@Column({type: 'text'})
|
@Column({ name: 'nir_chiffre', length: 15, nullable: true })
|
||||||
nir_encrypted: string;
|
nir?: string;
|
||||||
|
|
||||||
@Column({type: 'int'})
|
@Column({ name: 'nb_max_enfants', type: 'int', nullable: true })
|
||||||
max_children: number;
|
max_children?: number;
|
||||||
|
|
||||||
@Column({type: 'text'})
|
@Column({ name: 'biographie', type: 'text', nullable: true })
|
||||||
bio: string;
|
biography?: string;
|
||||||
|
|
||||||
@Column({type: 'boolean', default: true})
|
@Column({ name: 'disponible', type: 'boolean', default: true })
|
||||||
is_available: boolean;
|
available: boolean;
|
||||||
|
|
||||||
@Column({type: 'varchar'})
|
|
||||||
city: string;
|
|
||||||
|
|
||||||
|
@Column({ name: 'ville_residence', length: 100, nullable: true })
|
||||||
|
city?: string;
|
||||||
}
|
}
|
||||||
42
src/entities/avenants_contrats.entity.ts
Normal file
42
src/entities/avenants_contrats.entity.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
||||||
|
import { Contrat } from "./contrats.entity";
|
||||||
|
import { Users } from "./users.entity";
|
||||||
|
|
||||||
|
export enum StatutAvenantType {
|
||||||
|
PROPOSE = 'propose',
|
||||||
|
ACCEPTE = 'accepte',
|
||||||
|
REFUSE = 'refuse',
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity('avenants_contrats')
|
||||||
|
export class AvenantContrat {
|
||||||
|
// Define your columns and relationships here
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Contrat, { onDelete: 'CASCADE' })
|
||||||
|
@JoinColumn({ name: 'id_contrat' })
|
||||||
|
contrat: Contrat;
|
||||||
|
|
||||||
|
@Column({ type: 'jsonb', nullable: true, name: 'modifications' })
|
||||||
|
modifications?: any;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, { nullable: true })
|
||||||
|
@JoinColumn({ name: 'initie_par', referencedColumnName: 'id' })
|
||||||
|
initiator?: Users;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: StatutAvenantType,
|
||||||
|
enumName: 'statut_avenant_type',
|
||||||
|
default: StatutAvenantType.PROPOSE,
|
||||||
|
name: 'statut'
|
||||||
|
})
|
||||||
|
statut: StatutAvenantType;
|
||||||
|
|
||||||
|
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||||
|
createdAt: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||||
|
updatedAt: Date;
|
||||||
|
}
|
||||||
@ -1,60 +1,74 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
import {
|
||||||
import { Parents } from "./parents.entity";
|
Entity, PrimaryGeneratedColumn, Column,
|
||||||
import { ParentsChildren } from "./parents_children.entity";
|
OneToMany, ManyToMany, CreateDateColumn, JoinTable
|
||||||
import { Dossier } from "./dossiers.entity";
|
} from 'typeorm';
|
||||||
|
import { Parents } from './parents.entity';
|
||||||
|
import { ParentsChildren } from './parents_children.entity';
|
||||||
|
import { Dossier } from './dossiers.entity';
|
||||||
|
|
||||||
export enum ChildStatus {
|
export enum StatutEnfantType {
|
||||||
A_NAITRE = 'A_NAÎTRE',
|
A_NAITRE = 'a_naitre',
|
||||||
ACTIF = 'ACTIF',
|
ACTIF = 'actif',
|
||||||
SCOLARISE = 'SCOLARISE'
|
SCOLARISE = 'scolarise',
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity('children')
|
export enum GenreType {
|
||||||
export class Children {
|
H = 'H',
|
||||||
|
F = 'F',
|
||||||
|
AUTRE = 'Autre',
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity('enfants')
|
||||||
|
export class Children {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: StatutEnfantType,
|
||||||
|
enumName: 'statut_enfant_type',
|
||||||
|
name: 'statut'
|
||||||
|
})
|
||||||
|
status: StatutEnfantType;
|
||||||
|
|
||||||
|
@Column({ name: 'prenom', length: 100 })
|
||||||
first_name: string;
|
first_name: string;
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ name: 'nom', length: 100 })
|
||||||
last_name: string;
|
last_name: string;
|
||||||
|
|
||||||
@Column({ type: 'date', nullable: true })
|
|
||||||
birthdate: Date;
|
|
||||||
|
|
||||||
@Column({ type: 'date', nullable: true })
|
|
||||||
due_date: Date;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
photo_url: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
consent_photo: boolean;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamp', nullable: true })
|
|
||||||
consent_photo_at: Date;
|
|
||||||
|
|
||||||
@Column({nullable: true })
|
|
||||||
is_multiple: boolean
|
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
type: 'enum',
|
type: 'enum',
|
||||||
enum: ChildStatus,
|
enum: GenreType,
|
||||||
default: ChildStatus.A_NAITRE,
|
enumName: 'genre_type',
|
||||||
|
nullable: true,
|
||||||
|
name: 'genre'
|
||||||
})
|
})
|
||||||
status: ChildStatus;
|
gender?: GenreType;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@Column({ type: 'date', nullable: true, name: 'date_naissance' })
|
||||||
created_at: Date;
|
birthdate?: Date;
|
||||||
|
|
||||||
@UpdateDateColumn()
|
@Column({ type: 'date', nullable: true, name: 'date_prevue_naissance' })
|
||||||
updated_at: Date;
|
due_date?: Date;
|
||||||
|
|
||||||
@OneToMany(() => ParentsChildren, pc => pc.child, { onDelete: 'CASCADE' })
|
@Column({ nullable: true, name: 'photo_url' })
|
||||||
parentChildren: ParentsChildren[];
|
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)
|
@OneToMany(() => Dossier, d => d.child)
|
||||||
dossiers: Dossier[];
|
dossiers: Dossier[];
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/entities/contrats.entity.ts
Normal file
53
src/entities/contrats.entity.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { Column, CreateDateColumn, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
||||||
|
import { Dossier } from "./dossiers.entity";
|
||||||
|
|
||||||
|
export enum StatutContratType {
|
||||||
|
BROUILLON = 'brouillon',
|
||||||
|
EN_ATTENTE_SIGNATURE = 'en_attente_signature',
|
||||||
|
VALIDE = 'valide',
|
||||||
|
RESILIE = 'resilie',
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity('contrats')
|
||||||
|
export class Contrat {
|
||||||
|
// Define your columns and relationships here
|
||||||
|
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@OneToOne(() => Dossier, {onDelete: 'CASCADE'} )
|
||||||
|
@JoinColumn({ name: 'id_dossier'})
|
||||||
|
dossier: Dossier;
|
||||||
|
|
||||||
|
@Column({type: 'jsonb', nullable: true, name: 'planning'})
|
||||||
|
planning?: any;
|
||||||
|
|
||||||
|
@Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'tarif_horaire'})
|
||||||
|
hourly_rate?: string;
|
||||||
|
|
||||||
|
@Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'indemnites_repas'})
|
||||||
|
meal_indemnity?: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: StatutContratType,
|
||||||
|
default: StatutContratType.BROUILLON,
|
||||||
|
name: 'statut'
|
||||||
|
})
|
||||||
|
statut: StatutContratType;
|
||||||
|
|
||||||
|
@Column({type: 'boolean', default: false, name: 'signe_parent'})
|
||||||
|
signed_by_parent: boolean;
|
||||||
|
|
||||||
|
@Column({type: 'boolean', default: false, name: 'signe_am'})
|
||||||
|
signed_by_am: boolean;
|
||||||
|
|
||||||
|
@Column({type: 'timestamptz', nullable: true, name: 'finalise_le'})
|
||||||
|
finalized_at?: Date;
|
||||||
|
|
||||||
|
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||||
|
created_at: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||||
|
updated_at: Date;
|
||||||
|
}
|
||||||
@ -1,41 +1,60 @@
|
|||||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
import {
|
||||||
import { Parents } from "./parents.entity";
|
Entity, PrimaryGeneratedColumn, Column,
|
||||||
import { Children } from "./children.entity";
|
ManyToOne, OneToMany, CreateDateColumn, UpdateDateColumn, JoinColumn
|
||||||
|
} from 'typeorm';
|
||||||
|
import { Parents } from './parents.entity';
|
||||||
|
import { Children } from './children.entity';
|
||||||
|
import { Message } from './messages.entity';
|
||||||
|
|
||||||
|
export enum StatutDossierType {
|
||||||
|
ENVOYE = 'envoye',
|
||||||
|
ACCEPTE = 'accepte',
|
||||||
|
REFUSE = 'refuse',
|
||||||
|
}
|
||||||
|
|
||||||
@Entity('dossiers')
|
@Entity('dossiers')
|
||||||
export class Dossier {
|
export class Dossier {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@ManyToOne(() => Parents, p => p.dossiers, {onDelete: 'CASCADE'} )
|
@ManyToOne(() => Parents, p => p.dossiers, { onDelete: 'CASCADE', nullable: false })
|
||||||
@JoinColumn({ name: 'parent_id', referencedColumnName: 'user_id' })
|
@JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
|
||||||
parent: Parents;
|
parent: Parents;
|
||||||
|
|
||||||
@ManyToOne(() => Children, c => c.dossiers, {onDelete:'CASCADE'})
|
@ManyToOne(() => Children, c => c.dossiers, { onDelete: 'CASCADE', nullable: false })
|
||||||
@JoinColumn({ name: 'child_id', referencedColumnName: 'id' })
|
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
||||||
child: Children;
|
child: Children;
|
||||||
|
|
||||||
@Column({type: 'text', nullable: true})
|
@Column({ type: 'text', nullable: true, name: 'presentation' })
|
||||||
presentation: string;
|
presentation?: string;
|
||||||
|
|
||||||
@Column({type: 'varchar', nullable: true})
|
@Column({ type: 'varchar', length: 50, nullable: true, name: 'type_contrat' })
|
||||||
type_contract: string;
|
type_contrat?: string;
|
||||||
|
|
||||||
@Column({type:'boolean', nullable: true})
|
@Column({ type: 'boolean', default: false, name: 'repas' })
|
||||||
meals: boolean;
|
meals: boolean;
|
||||||
|
|
||||||
@Column({type: 'decimal', nullable: true})
|
@Column({ type: 'numeric', precision: 10, scale: 2, nullable: true, name: 'budget' })
|
||||||
budget: number;
|
budget?: number;
|
||||||
|
|
||||||
@Column({type: 'json', nullable: true})
|
@Column({ type: 'jsonb', nullable: true, name: 'planning_souhaite' })
|
||||||
desired_schedule: any;
|
desired_schedule?: any;
|
||||||
|
|
||||||
@Column({type: 'varchar', default: 'sent'})
|
@Column({
|
||||||
status: string;
|
type: 'enum',
|
||||||
|
enum: StatutDossierType,
|
||||||
|
enumName: 'statut_dossier_type',
|
||||||
|
default: StatutDossierType.ENVOYE,
|
||||||
|
name: 'statut'
|
||||||
|
})
|
||||||
|
status: StatutDossierType;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
|
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||||
updated_at: Date;
|
updated_at: Date;
|
||||||
|
|
||||||
|
@OneToMany(() => Message, m => m.dossier)
|
||||||
|
messages: Message[];
|
||||||
}
|
}
|
||||||
29
src/entities/messages.entity.ts
Normal file
29
src/entities/messages.entity.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import {
|
||||||
|
Entity, PrimaryGeneratedColumn, Column,
|
||||||
|
ManyToOne, JoinColumn, CreateDateColumn
|
||||||
|
} from 'typeorm';
|
||||||
|
import { Dossier } from './dossiers.entity';
|
||||||
|
import { Users } from './users.entity';
|
||||||
|
|
||||||
|
@Entity('messages')
|
||||||
|
export class Message {
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Dossier, d => d.messages, { onDelete: 'CASCADE', nullable: false })
|
||||||
|
@JoinColumn({ name: 'id_dossier' })
|
||||||
|
dossier: Dossier;
|
||||||
|
|
||||||
|
@ManyToOne(() => Users, u => u.messages, { onDelete: 'CASCADE', nullable: false })
|
||||||
|
@JoinColumn({ name: 'id_expediteur' })
|
||||||
|
sender: Users;
|
||||||
|
|
||||||
|
@Column({ type: 'text', name: 'contenu' })
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Column({ type: 'boolean', name: 're_redige_par_ia', default: false })
|
||||||
|
reRedigeParIA: boolean;
|
||||||
|
|
||||||
|
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||||
|
created_at: Date;
|
||||||
|
}
|
||||||
@ -1,28 +1,31 @@
|
|||||||
import { Column, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn } from "typeorm";
|
import {
|
||||||
import { Users } from "./user.entity";
|
Entity, PrimaryColumn, OneToOne, JoinColumn,
|
||||||
import { ParentsChildren } from "./parents_children.entity";
|
ManyToOne, OneToMany
|
||||||
import { Dossier } from "./dossiers.entity";
|
} from 'typeorm';
|
||||||
|
import { Users } from './users.entity';
|
||||||
|
import { ParentsChildren } from './parents_children.entity';
|
||||||
|
import { Dossier } from './dossiers.entity';
|
||||||
|
|
||||||
@Entity('parents')
|
@Entity('parents')
|
||||||
export class Parents {
|
export class Parents {
|
||||||
|
// PK = FK vers utilisateurs.id
|
||||||
@PrimaryColumn('uuid')
|
@PrimaryColumn('uuid', { name: 'id_utilisateur' })
|
||||||
user_id: string;
|
user_id: string;
|
||||||
|
|
||||||
@OneToOne(() => Users, user => user.parent, { onDelete: 'CASCADE' })
|
@OneToOne(() => Users, user => user.parent, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'user_id' })
|
@JoinColumn({ name: 'id_utilisateur', referencedColumnName: 'id' })
|
||||||
user: Users;
|
user: Users;
|
||||||
|
|
||||||
@Column({ type: 'uuid', nullable: true })
|
// Co-parent (nullable) → FK vers utilisateurs.id
|
||||||
co_parent_id?: string;
|
@ManyToOne(() => Users, { nullable: true })
|
||||||
|
@JoinColumn({ name: 'id_co_parent', referencedColumnName: 'id' })
|
||||||
@OneToOne(() => Users)
|
|
||||||
@JoinColumn({ name: 'co_parent_id' })
|
|
||||||
co_parent?: Users;
|
co_parent?: Users;
|
||||||
|
|
||||||
@OneToMany(() => ParentsChildren, pc => pc.parent, { onDelete: 'CASCADE' })
|
// Lien vers enfants via la table enfants_parents
|
||||||
|
@OneToMany(() => ParentsChildren, pc => pc.parent)
|
||||||
parentChildren: ParentsChildren[];
|
parentChildren: ParentsChildren[];
|
||||||
|
|
||||||
|
// Lien vers les dossiers de ce parent
|
||||||
@OneToMany(() => Dossier, d => d.parent)
|
@OneToMany(() => Dossier, d => d.parent)
|
||||||
dossiers: Dossier[];
|
dossiers: Dossier[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,22 @@
|
|||||||
import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
import {
|
||||||
import { Parents } from "./parents.entity";
|
Entity, ManyToOne, JoinColumn, PrimaryColumn
|
||||||
import { Children } from "./children.entity";
|
} from 'typeorm';
|
||||||
|
import { Parents } from './parents.entity';
|
||||||
|
import { Children } from './children.entity';
|
||||||
|
|
||||||
@Entity('parents_children')
|
@Entity('enfants_parents')
|
||||||
export class ParentsChildren {
|
export class ParentsChildren {
|
||||||
|
@PrimaryColumn('uuid', { name: 'id_parent' })
|
||||||
|
id_parent: string;
|
||||||
|
|
||||||
@PrimaryColumn('uuid')
|
@PrimaryColumn('uuid', { name: 'id_enfant' })
|
||||||
parent_id: string;
|
id_enfant: string;
|
||||||
|
|
||||||
@PrimaryColumn('uuid')
|
@ManyToOne(() => Parents, p => p.parentChildren, { onDelete: 'CASCADE' })
|
||||||
child_id: string;
|
@JoinColumn({ name: 'id_parent', referencedColumnName: 'user_id' })
|
||||||
|
|
||||||
@ManyToOne(() => Parents, (parent) => parent.parentChildren, {onDelete: 'CASCADE'})
|
|
||||||
@JoinColumn({ name: 'parent_id', referencedColumnName: 'user_id' })
|
|
||||||
parent: Parents;
|
parent: Parents;
|
||||||
|
|
||||||
@ManyToOne(() => Children, (child) => child.parentChildren, {onDelete: 'CASCADE'})
|
@ManyToOne(() => Children, c => c.parentLinks, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'child_id', referencedColumnName: 'id' })
|
@JoinColumn({ name: 'id_enfant', referencedColumnName: 'id' })
|
||||||
child: Children;
|
child: Children;
|
||||||
}
|
}
|
||||||
@ -1,73 +0,0 @@
|
|||||||
import {
|
|
||||||
Entity, PrimaryGeneratedColumn, Column,
|
|
||||||
CreateDateColumn, UpdateDateColumn,
|
|
||||||
OneToOne
|
|
||||||
} from 'typeorm';
|
|
||||||
import { AssistanteMaternelle } from './assistantes_maternelles.entity';
|
|
||||||
import { Parents } from './parents.entity';
|
|
||||||
export enum UserRole {
|
|
||||||
PARENT = 'PARENT',
|
|
||||||
ASSISTANT = 'ASSISTANT',
|
|
||||||
GESTIONNAIRE = 'GESTIONNAIRE',
|
|
||||||
ADMIN = 'ADMIN',
|
|
||||||
}
|
|
||||||
|
|
||||||
@Entity('users')
|
|
||||||
export class Users {
|
|
||||||
@PrimaryGeneratedColumn('uuid')
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ unique: true })
|
|
||||||
email: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
password_hash: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
first_name: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
last_name: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'enum',
|
|
||||||
enum: UserRole,
|
|
||||||
default: UserRole.PARENT,
|
|
||||||
})
|
|
||||||
role: UserRole;
|
|
||||||
|
|
||||||
@Column({ default: 'pending' })
|
|
||||||
status: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
phone: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
address: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
photo_url: string;
|
|
||||||
|
|
||||||
@Column({ default: false })
|
|
||||||
consent_photo: boolean;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamp', nullable: true })
|
|
||||||
consent_photo_at: Date;
|
|
||||||
|
|
||||||
@Column({ default: false })
|
|
||||||
must_change_password: boolean;
|
|
||||||
|
|
||||||
@CreateDateColumn()
|
|
||||||
created_at: Date;
|
|
||||||
|
|
||||||
@UpdateDateColumn()
|
|
||||||
updated_at: Date;
|
|
||||||
|
|
||||||
@OneToOne(() => AssistanteMaternelle, a => a.user)
|
|
||||||
assistanteMaternelle?: AssistanteMaternelle;
|
|
||||||
|
|
||||||
@OneToOne(() => Parents, p => p.user)
|
|
||||||
parent?: Parents;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
106
src/entities/users.entity.ts
Normal file
106
src/entities/users.entity.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import {
|
||||||
|
Entity, PrimaryGeneratedColumn, Column,
|
||||||
|
CreateDateColumn, UpdateDateColumn,
|
||||||
|
OneToOne, OneToMany
|
||||||
|
} from 'typeorm';
|
||||||
|
import { AssistanteMaternelle } from './assistantes_maternelles.entity';
|
||||||
|
import { Parents } from './parents.entity';
|
||||||
|
import { Message } from './messages.entity';
|
||||||
|
|
||||||
|
// Enums alignés avec la BDD PostgreSQL
|
||||||
|
export enum RoleType {
|
||||||
|
PARENT = 'parent',
|
||||||
|
GESTIONNAIRE = 'gestionnaire',
|
||||||
|
SUPER_ADMIN = 'super_admin',
|
||||||
|
ASSISTANTE_MATERNELLE = 'assistante_maternelle',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum GenreType {
|
||||||
|
H = 'H',
|
||||||
|
F = 'F',
|
||||||
|
AUTRE = 'Autre',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum StatutUtilisateurType {
|
||||||
|
EN_ATTENTE = 'en_attente',
|
||||||
|
ACTIF = 'actif',
|
||||||
|
SUSPENDU = 'suspendu',
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity('utilisateurs')
|
||||||
|
export class Users {
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ unique: true, name: 'courriel' })
|
||||||
|
email: string;
|
||||||
|
|
||||||
|
@Column({ name: 'mot_de_passe_hash' })
|
||||||
|
password_hash: string;
|
||||||
|
|
||||||
|
@Column({ name: 'prenom', nullable: true })
|
||||||
|
first_name: string;
|
||||||
|
|
||||||
|
@Column({ name: 'nom', nullable: true })
|
||||||
|
last_name: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: GenreType,
|
||||||
|
enumName: 'genre_type', // correspond à l'enum SQL
|
||||||
|
nullable: true,
|
||||||
|
name: 'genre'
|
||||||
|
})
|
||||||
|
gender?: GenreType;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: RoleType,
|
||||||
|
enumName: 'role_type',
|
||||||
|
name: 'role'
|
||||||
|
})
|
||||||
|
role: RoleType;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'enum',
|
||||||
|
enum: StatutUtilisateurType,
|
||||||
|
enumName: 'statut_utilisateur_type',
|
||||||
|
default: StatutUtilisateurType.EN_ATTENTE,
|
||||||
|
name: 'statut'
|
||||||
|
})
|
||||||
|
status: StatutUtilisateurType;
|
||||||
|
|
||||||
|
@Column({ nullable: true, name: 'telephone' })
|
||||||
|
phone?: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true, name: 'adresse' })
|
||||||
|
address?: string;
|
||||||
|
|
||||||
|
@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: 'changement_mdp_obligatoire' })
|
||||||
|
must_change_password: boolean;
|
||||||
|
|
||||||
|
@CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
|
||||||
|
created_at: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
|
||||||
|
updated_at: Date;
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
@OneToOne(() => AssistanteMaternelle, a => a.user)
|
||||||
|
assistanteMaternelle?: AssistanteMaternelle;
|
||||||
|
|
||||||
|
@OneToOne(() => Parents, p => p.user)
|
||||||
|
parent?: Parents;
|
||||||
|
|
||||||
|
@OneToMany(() => Message, m => m.sender)
|
||||||
|
messages?: Message[];
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user