mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 10:30:17 +01:00
ajout endpoint POST pour ajout avis
This commit is contained in:
@@ -37,9 +37,19 @@ const addReview = (review, authorId, sourceId) => {
|
||||
}
|
||||
|
||||
export const addReviewFromRequest = async (req,res) => {
|
||||
const author = new Auteur(req.body.auteur_age,req.body.auteur_sexe);
|
||||
const review = new Review(author, req.body.note, req.body.source, req.body.message, req.body.notes_autre)
|
||||
let authorId = await addAuteur(author);
|
||||
let sourceId = await getSourceId(review.source);
|
||||
await addReview(review, authorId, sourceId )
|
||||
try {
|
||||
let notes_autre = {}
|
||||
try{
|
||||
notes_autre = JSON.parse(req.body.notes_autre);
|
||||
}catch(err){};
|
||||
|
||||
const author = new Auteur(req.body.auteur_age,req.body.auteur_sexe);
|
||||
const review = new Review(author, req.body.note, req.body.source, req.body.commentaire, notes_autre)
|
||||
let authorId = await addAuteur(author);
|
||||
let sourceId = await getSourceId(review.source);
|
||||
await addReview(review, authorId, sourceId );
|
||||
res.send("success")
|
||||
}catch(err) {
|
||||
res.status(500).send("Error : " + err.message)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user