generated from WildCodeSchool/create-js-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from WildCodeSchool/course_cvid
Course cvid
- Loading branch information
Showing
8 changed files
with
214 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,35 +26,27 @@ CREATE TABLE user ( | |
-- id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) | ||
-- ); | ||
|
||
-- INSERT INTO | ||
-- competence (name) | ||
-- values ("html"), | ||
-- ("css"), | ||
-- ("javascript"), | ||
-- ("angular"), | ||
-- ("react"), | ||
-- ("php"), | ||
-- ("symphony"), | ||
-- ("git"), | ||
-- ("github"), | ||
-- ("trello"); | ||
|
||
-- CREATE | ||
-- TABLE | ||
-- competence ( | ||
-- id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
-- -- name VARCHAR(100), | ||
-- html TEXT, | ||
-- css TEXT, | ||
-- javascript TEXT, | ||
-- angular TEXT, | ||
-- react TEXT, | ||
-- php TEXT, | ||
-- symphony TEXT, | ||
-- git TEXT, | ||
-- github TEXT, | ||
-- trello TEXT | ||
-- ); | ||
DROP TABLE IF EXISTS competence; | ||
|
||
CREATE TABLE | ||
competence ( | ||
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
name VARCHAR(100) | ||
); | ||
|
||
INSERT INTO | ||
competence (name) | ||
values ("html"), | ||
("css"), | ||
("javascript"), | ||
("angular"), | ||
("react"), | ||
("php"), | ||
("symphony"), | ||
("git"), | ||
("github"), | ||
("trello"); | ||
|
||
DROP TABLE IF EXISTS cv; | ||
|
||
CREATE TABLE cv ( | ||
|
@@ -113,12 +105,28 @@ VALUES ( | |
Nationalité française, en règle avec les obligations du service national JDC et jouissant de ses droits civiques.", "Junior", "Présent", "25k €/an", "Votre spécialité consiste à développer des logiciels au profit du ministère des Armées au sein d'un centre de développement. Sous la conduite d'un chef de projet, vous assurez la maintenance d'applications existantes et vous concevez de nouveaux logiciels liés aux besoins des armées. Vous soutenez les forces déployées depuis le territoire national et vous pouvez éventuellement être projetés sur des postes en dehors de votre compétence principale de développeur. Au bout de 4 à 6 ans, vous pouvez évoluer vers les métiers de la cybersécurité.", "[email protected]" | ||
); | ||
|
||
DROP TABLE IF EXISTS user_competence; | ||
-- Créer la table "user_competence" | ||
CREATE TABLE user_competence ( | ||
user_id INT, html BOOLEAN, css BOOLEAN, javascript BOOLEAN, angular BOOLEAN, react BOOLEAN, php BOOLEAN, symphony BOOLEAN, git BOOLEAN, github BOOLEAN, trello BOOLEAN, PRIMARY KEY (user_id), FOREIGN KEY (user_id) REFERENCES user (id) | ||
); | ||
|
||
CREATE TABLE upload ( | ||
id int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, url varchar(255) NOT NULL, unique (url), created_at timestamp default CURRENT_TIMESTAMP | ||
); | ||
); | ||
|
||
DROP TABLE IF EXISTS user_competence; | ||
|
||
CREATE TABLE | ||
user_competence ( | ||
id int PRIMARY KEY NOT NULL AUTO_INCREMENT, | ||
user_id INT NOT NULL, | ||
competence_id INT NOT NULL, | ||
FOREIGN KEY (user_id) REFERENCES user (id), | ||
FOREIGN KEY (competence_id) REFERENCES competence (id) | ||
); | ||
|
||
DROP TABLE IF EXISTS offer_competence; | ||
|
||
CREATE TABLE | ||
offer_competence ( | ||
id int PRIMARY KEY NOT NULL AUTO_INCREMENT, | ||
offer_id INT NOT NULL, | ||
competence_id INT NOT NULL, | ||
FOREIGN KEY (offer_id) REFERENCES offer (id), | ||
FOREIGN KEY (competence_id) REFERENCES competence (id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const AbstractManager = require("./AbstractManager"); | ||
|
||
class OfferCompetenceManager extends AbstractManager { | ||
constructor() { | ||
super({ table: "offer_competence" }); | ||
} | ||
|
||
async addOfferCompetences(offerId, body) { | ||
const uniqValues = new Set(body.competences ?? []); | ||
const [offerCompetences] = await this.database.query( | ||
`SELECT competence_id from ${this.table} where offer_id = ?`, | ||
[offerId] | ||
); | ||
|
||
offerCompetences.forEach((offerCompetence) => { | ||
if (uniqValues.has(offerCompetence.competence_id)) { | ||
uniqValues.delete(offerCompetence.competence_id); | ||
} | ||
}); | ||
|
||
if (!uniqValues.size) { | ||
return []; | ||
} | ||
|
||
const sqlValues = []; | ||
let sql = `insert into ${this.table} (offer_id, competence_id) VALUES`; | ||
|
||
[...uniqValues.values()].forEach((competenceId) => { | ||
sql += `${sqlValues.length > 0 ? "," : ""} (?,?)`; | ||
sqlValues.push(offerId); | ||
sqlValues.push(competenceId); | ||
}); | ||
|
||
const [result] = await this.database.query(sql, sqlValues); | ||
return result; | ||
} | ||
|
||
async getOfferCompetences(offerId) { | ||
const [result] = await this.database.query( | ||
`SELECT competence.* FROM competence LEFT JOIN ${this.table} ON competence.id = ${this.table}.competence_id WHERE ${this.table}.offer_id = ?`, | ||
offerId | ||
); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
module.exports = OfferCompetenceManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const AbstractManager = require("./AbstractManager"); | ||
|
||
class UserCompetenceManager extends AbstractManager { | ||
constructor() { | ||
super({ table: "user_competence" }); | ||
} | ||
|
||
async addUserCompetences(userId, body) { | ||
const uniqValues = new Set(body.competences ?? []); | ||
const [userCompetences] = await this.database.query( | ||
`SELECT competence_id from ${this.table} where user_id = ?`, | ||
[userId] | ||
); | ||
|
||
userCompetences.forEach((userCompetence) => { | ||
if (uniqValues.has(userCompetence.competence_id)) { | ||
uniqValues.delete(userCompetence.competence_id); | ||
} | ||
}); | ||
|
||
if (!uniqValues.size) { | ||
return []; | ||
} | ||
|
||
const sqlValues = []; | ||
let sql = `insert into ${this.table} (user_id, competence_id) VALUES`; | ||
|
||
[...uniqValues.values()].forEach((competenceId) => { | ||
sql += `${sqlValues.length > 0 ? "," : ""} (?,?)`; | ||
sqlValues.push(userId); | ||
sqlValues.push(competenceId); | ||
}); | ||
|
||
const [result] = await this.database.query(sql, sqlValues); | ||
return result; | ||
} | ||
|
||
async getUserCompetences(userId) { | ||
const [result] = await this.database.query( | ||
`SELECT competence.* FROM competence LEFT JOIN ${this.table} ON competence.id = ${this.table}.competence_id WHERE ${this.table}.user_id = ?`, | ||
userId | ||
); | ||
|
||
return result; | ||
} | ||
} | ||
|
||
module.exports = UserCompetenceManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters