added parents users and assistants
This commit is contained in:
parent
74ad0c532f
commit
6033fb551a
41
src/entities/assistantes_maternelles.entity.ts
Normal file
41
src/entities/assistantes_maternelles.entity.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm";
|
||||
import { Users } from "./user.entity";
|
||||
|
||||
@Entity('assistantes_maternelles')
|
||||
export class AssistanteMaternelle {
|
||||
// Declarer les proprietes ici
|
||||
@PrimaryColumn('uuid')
|
||||
user_id: string;
|
||||
|
||||
@OneToOne(() => Users, user => user.assistanteMaternelle, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user: Users;
|
||||
|
||||
@Column({type: 'varchar'})
|
||||
approval_number: string;
|
||||
|
||||
@Column({type: 'date'})
|
||||
birthdate: Date;
|
||||
|
||||
@Column({type: 'varchar'})
|
||||
birthplace_city: string;
|
||||
|
||||
@Column({type: 'varchar'})
|
||||
birthplace_country: string;
|
||||
|
||||
@Column({type: 'text'})
|
||||
nir_encrypted: string;
|
||||
|
||||
@Column({type: 'int'})
|
||||
max_children: number;
|
||||
|
||||
@Column({type: 'text'})
|
||||
bio: string;
|
||||
|
||||
@Column({type: 'boolean', default: true})
|
||||
is_available: boolean;
|
||||
|
||||
@Column({type: 'varchar'})
|
||||
city: string;
|
||||
|
||||
}
|
||||
0
src/entities/children.entity.ts
Normal file
0
src/entities/children.entity.ts
Normal file
20
src/entities/parents.entity.ts
Normal file
20
src/entities/parents.entity.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Column, Entity, JoinColumn, OneToOne, PrimaryColumn } from "typeorm";
|
||||
import { Users } from "./user.entity";
|
||||
|
||||
@Entity('parents')
|
||||
export class Parents {
|
||||
|
||||
@PrimaryColumn('uuid')
|
||||
user_id: string;
|
||||
|
||||
@OneToOne(() => Users, user => user.parent, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user: Users;
|
||||
|
||||
@Column({ type: 'uuid', nullable: true })
|
||||
co_parent_id?: string;
|
||||
|
||||
@OneToOne(() => Users)
|
||||
@JoinColumn({ name: 'co_parent_id' })
|
||||
co_parent?: Users;
|
||||
}
|
||||
73
src/entities/user.entity.ts
Normal file
73
src/entities/user.entity.ts
Normal file
@ -0,0 +1,73 @@
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user