1- import { hashPassword , ProposedSectionEntity , UserEntity } from "@libs/users-backend" ;
1+ import {
2+ hashPassword ,
3+ SectionTemplatesEntity ,
4+ UserEntity ,
5+ CurriculumEntity ,
6+ SectionsEntity ,
7+ SectionItemsEntity ,
8+ } from "@libs/users-backend" ;
29import type { EntityManager } from "@mikro-orm/core" ;
310import { Seeder } from "@mikro-orm/seeder" ;
11+ import personnalInformationsJsonSchema from "./models/personal-informations.schema.json" with { type : "json" } ;
12+ import formationsJsonSchema from "./models/formations.schema.json" with { type : "json" } ;
13+ import langueJsonSchema from "./models/langues.schema.json" with { type : "json" } ;
14+ import centresInteretsJsonSchema from "./models/centres-interets.schema.json" with { type : "json" } ;
15+ import competencesJsonSchema from "./models/competences.schema.json" with { type : "json" } ;
16+ import experiencesJsonSchema from "./models/experiences.schema.json" with { type : "json" } ;
17+ import profilJsonSchema from "./models/profil.schema.json" with { type : "json" } ;
18+ import referencesJsonSchema from "./models/references.schema.json" with { type : "json" } ;
419
520export class DatabaseSeeder extends Seeder {
621 async run ( em : EntityManager ) {
@@ -15,22 +30,125 @@ export class DatabaseSeeder extends Seeder {
1530 password : hashedPassword ,
1631 } ) ;
1732
18- em . create ( ProposedSectionEntity , {
19- id : "e2e-proposed-section-1" ,
20- title : "Informations personnelles" ,
33+ const template1 = em . create ( SectionTemplatesEntity , {
34+ id : "e2e-section-template-1" ,
35+ label : "Informations personnelles" ,
36+ jsonSchema : personnalInformationsJsonSchema ,
2137 position : 1 ,
2238 } ) ;
2339
24- em . create ( ProposedSectionEntity , {
25- id : "e2e-proposed-section-2" ,
26- title : "Expérience professionnelle" ,
40+ const template2 = em . create ( SectionTemplatesEntity , {
41+ id : "e2e-section-template-2" ,
42+ label : "Formations" ,
43+ jsonSchema : formationsJsonSchema ,
2744 position : 2 ,
2845 } ) ;
2946
30- em . create ( ProposedSectionEntity , {
31- id : "e2e-proposed-section-3" ,
32- title : "Formation et diplômes" ,
47+ em . create ( SectionTemplatesEntity , {
48+ id : "e2e-section-template-3" ,
49+ label : "Expériences professionnelles" ,
50+ jsonSchema : experiencesJsonSchema ,
3351 position : 3 ,
3452 } ) ;
53+
54+ em . create ( SectionTemplatesEntity , {
55+ id : "e2e-section-template-4" ,
56+ label : "Compétences" ,
57+ jsonSchema : competencesJsonSchema ,
58+ position : 4 ,
59+ } ) ;
60+
61+ em . create ( SectionTemplatesEntity , {
62+ id : "e2e-section-template-5" ,
63+ label : "Centres d'intérêts" ,
64+ jsonSchema : centresInteretsJsonSchema ,
65+ position : 5 ,
66+ } ) ;
67+
68+ em . create ( SectionTemplatesEntity , {
69+ id : "e2e-section-template-6" ,
70+ label : "Profil" ,
71+ jsonSchema : profilJsonSchema ,
72+ position : 6 ,
73+ } ) ;
74+
75+ em . create ( SectionTemplatesEntity , {
76+ id : "e2e-section-template-7" ,
77+ label : "Références" ,
78+ jsonSchema : referencesJsonSchema ,
79+ position : 7 ,
80+ } ) ;
81+
82+ em . create ( SectionTemplatesEntity , {
83+ id : "e2e-section-template-8" ,
84+ label : "Langues" ,
85+ jsonSchema : langueJsonSchema ,
86+ position : 8 ,
87+ } ) ;
88+
89+ const curriculum = em . create ( CurriculumEntity , {
90+ id : "e2e-curriculum" ,
91+ userId : "e2e-login-user" ,
92+ title : "Mon CV" ,
93+ createdAt : new Date ( ) ,
94+ updatedAt : new Date ( ) ,
95+ } ) ;
96+
97+ const section1 = em . create ( SectionsEntity , {
98+ id : "e2e-section-1" ,
99+ curriculum,
100+ template : template1 ,
101+ title : "Informations personnelles" ,
102+ position : 1 ,
103+ } ) ;
104+
105+ const section2 = em . create ( SectionsEntity , {
106+ id : "e2e-section-2" ,
107+ curriculum,
108+ template : template2 ,
109+ title : "Formations" ,
110+ position : 2 ,
111+ } ) ;
112+
113+ em . create ( SectionItemsEntity , {
114+ id : "e2e-section-item-1" ,
115+ section : section1 ,
116+ position : 1 ,
117+ jsonData : {
118+ firstName : "Amaury" ,
119+ lastName : "Deflorenne" ,
120+ email : "test@gmail.com" ,
121+ phone : "0601020304" ,
122+ address : "123 rue de la paix, 75000 Paris" ,
123+ } ,
124+ } ) ;
125+
126+ em . create ( SectionItemsEntity , {
127+ id : "e2e-section-item-2" ,
128+ section : section2 ,
129+ position : 1 ,
130+ jsonData : {
131+ school : "Université de Lyon" ,
132+ degree : "Master Informatique" ,
133+ field : "Informatique" ,
134+ startDate : "2021-09-01" ,
135+ endDate : "2023-06-30" ,
136+ description : "Description de ma formation en informatique à l'Université de Lyon." ,
137+ } ,
138+ } ) ;
139+
140+ em . create ( SectionItemsEntity , {
141+ id : "e2e-section-item-3" ,
142+ section : section2 ,
143+ position : 2 ,
144+ jsonData : {
145+ school : "Université de Paris" ,
146+ degree : "Licence Informatique" ,
147+ field : "Informatique" ,
148+ startDate : "2018-09-01" ,
149+ endDate : "2021-06-30" ,
150+ description : "Description de ma formation en informatique à l'Université de Paris." ,
151+ } ,
152+ } ) ;
35153 }
36154}
0 commit comments