dossiers added + parent and children updated
This commit is contained in:
parent
6033fb551a
commit
b75034739c
@ -0,0 +1,60 @@
|
|||||||
|
import { Column, CreateDateColumn, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
||||||
|
import { Parents } from "./parents.entity";
|
||||||
|
import { ParentsChildren } from "./parents_children.entity";
|
||||||
|
import { Dossier } from "./dossiers.entity";
|
||||||
|
|
||||||
|
export enum ChildStatus {
|
||||||
|
A_NAITRE = 'A_NAÎTRE',
|
||||||
|
ACTIF = 'ACTIF',
|
||||||
|
SCOLARISE = 'SCOLARISE'
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity('children')
|
||||||
|
export class Children {
|
||||||
|
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
first_name: string;
|
||||||
|
|
||||||
|
@Column({ nullable: true })
|
||||||
|
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({
|
||||||
|
type: 'enum',
|
||||||
|
enum: ChildStatus,
|
||||||
|
default: ChildStatus.A_NAITRE,
|
||||||
|
})
|
||||||
|
status: ChildStatus;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
created_at: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn()
|
||||||
|
updated_at: Date;
|
||||||
|
|
||||||
|
@OneToMany(() => ParentsChildren, pc => pc.child, { onDelete: 'CASCADE' })
|
||||||
|
parentChildren: ParentsChildren[];
|
||||||
|
|
||||||
|
@OneToMany(() => Dossier, d => d.child)
|
||||||
|
dossiers: Dossier[];
|
||||||
|
}
|
||||||
41
src/entities/dossiers.entity.ts
Normal file
41
src/entities/dossiers.entity.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
||||||
|
import { Parents } from "./parents.entity";
|
||||||
|
import { Children } from "./children.entity";
|
||||||
|
|
||||||
|
@Entity('dossiers')
|
||||||
|
export class Dossier {
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Parents, p => p.dossiers, {onDelete: 'CASCADE'} )
|
||||||
|
@JoinColumn({ name: 'parent_id', referencedColumnName: 'user_id' })
|
||||||
|
parent: Parents;
|
||||||
|
|
||||||
|
@ManyToOne(() => Children, c => c.dossiers, {onDelete:'CASCADE'})
|
||||||
|
@JoinColumn({ name: 'child_id', referencedColumnName: 'id' })
|
||||||
|
child: Children;
|
||||||
|
|
||||||
|
@Column({type: 'text', nullable: true})
|
||||||
|
presentation: string;
|
||||||
|
|
||||||
|
@Column({type: 'varchar', nullable: true})
|
||||||
|
type_contract: string;
|
||||||
|
|
||||||
|
@Column({type:'boolean', nullable: true})
|
||||||
|
meals: boolean;
|
||||||
|
|
||||||
|
@Column({type: 'decimal', nullable: true})
|
||||||
|
budget: number;
|
||||||
|
|
||||||
|
@Column({type: 'json', nullable: true})
|
||||||
|
desired_schedule: any;
|
||||||
|
|
||||||
|
@Column({type: 'varchar', default: 'sent'})
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
created_at: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn()
|
||||||
|
updated_at: Date;
|
||||||
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm";
|
import { Column, Entity, JoinColumn, OneToMany, OneToOne, PrimaryColumn } from "typeorm";
|
||||||
import { Users } from "./user.entity";
|
import { Users } from "./user.entity";
|
||||||
|
import { ParentsChildren } from "./parents_children.entity";
|
||||||
|
import { Dossier } from "./dossiers.entity";
|
||||||
|
|
||||||
@Entity('parents')
|
@Entity('parents')
|
||||||
export class Parents {
|
export class Parents {
|
||||||
@ -17,4 +19,10 @@ export class Parents {
|
|||||||
@OneToOne(() => Users)
|
@OneToOne(() => Users)
|
||||||
@JoinColumn({ name: 'co_parent_id' })
|
@JoinColumn({ name: 'co_parent_id' })
|
||||||
co_parent?: Users;
|
co_parent?: Users;
|
||||||
|
|
||||||
|
@OneToMany(() => ParentsChildren, pc => pc.parent, { onDelete: 'CASCADE' })
|
||||||
|
parentChildren: ParentsChildren[];
|
||||||
|
|
||||||
|
@OneToMany(() => Dossier, d => d.parent)
|
||||||
|
dossiers: Dossier[];
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/entities/parents_children.entity.ts
Normal file
21
src/entities/parents_children.entity.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { Parents } from "./parents.entity";
|
||||||
|
import { Children } from "./children.entity";
|
||||||
|
|
||||||
|
@Entity('parents_children')
|
||||||
|
export class ParentsChildren {
|
||||||
|
|
||||||
|
@PrimaryColumn('uuid')
|
||||||
|
parent_id: string;
|
||||||
|
|
||||||
|
@PrimaryColumn('uuid')
|
||||||
|
child_id: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Parents, (parent) => parent.parentChildren, {onDelete: 'CASCADE'})
|
||||||
|
@JoinColumn({ name: 'parent_id', referencedColumnName: 'user_id' })
|
||||||
|
parent: Parents;
|
||||||
|
|
||||||
|
@ManyToOne(() => Children, (child) => child.parentChildren, {onDelete: 'CASCADE'})
|
||||||
|
@JoinColumn({ name: 'child_id', referencedColumnName: 'id' })
|
||||||
|
child: Children;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user