Mise à jour de controleurs, models et routes

This commit is contained in:
Rampeur
2025-08-19 05:13:24 +02:00
parent f8d8ff2329
commit b1513dccdd
21 changed files with 905 additions and 113 deletions
+24
View File
@@ -26,6 +26,30 @@ class ArticleService {
order: [['createdAt', 'DESC']],
});
}
static async getArticleBySlug(slug) {
const articles = await Article.findAll({
where: { slug },
include: [
{ model: DB.Tag, as: "tagNameTagTagLists", attributes: ["name"], through: { attributes: [] } },
{ model: DB.User, as: "author", attributes: { exclude: ["email", "phone", "salt", "hash"] } },
//{ model: DB.User, as: "author", attributes: { include: ["id", "username", "image", "role"] } },
],
order: [['createdAt', 'DESC']],
});
/*
.then(data => {
data.tagList = data.tagNameTagTagLists;
delete data.tagNameTagTagLists;
return data;
});
*/
//let article = articles[0];
//article.tagList = article.tagNameTagTagLists;
//delete article.tagNameTagTagLists;
return articles[0];
}
}
module.exports = ArticleService;
+5 -1
View File
@@ -18,7 +18,11 @@ class UserService {
}
static async getUserByEmail(email) {
return User.findOne(email);
return User.findOne({ where: { email: email } });
}
static async updateUser(data) {
return User.update(data);
}
}