update
All checks were successful
Deploy to Production / deploy (push) Successful in 20s

This commit is contained in:
vuongps38770
2026-02-28 20:00:38 +07:00
parent f96833a7e4
commit 72283443ab
15 changed files with 972 additions and 318 deletions

View File

@@ -127,6 +127,8 @@ exports.getAllSentences = async (req, res) => {
topic,
text,
search,
status,
sort,
is_active = true
} = req.query;
@@ -137,6 +139,11 @@ exports.getAllSentences = async (req, res) => {
where.is_active = is_active === 'true' || is_active === true;
}
// Status filter (0 = chưa duyệt, 1 = đã duyệt, undefined = all)
if (status !== undefined && status !== '' && status !== 'all') {
where.status = parseInt(status);
}
if (category) {
where.category = category;
}
@@ -156,11 +163,19 @@ exports.getAllSentences = async (req, res) => {
];
}
// Sort order
let order = [['created_at', 'DESC']]; // default
if (sort === 'updated_at') {
order = [['updated_at', 'DESC']];
} else if (sort === 'alphabet') {
order = [['text', 'ASC']];
}
const { count, rows } = await Sentences.findAndCountAll({
where,
limit: parseInt(limit),
offset: parseInt(offset),
order: [['created_at', 'DESC']]
order
});
res.json({