add: feature reminder custom device with cron-job

This commit is contained in:
2026-06-23 21:59:02 +07:00
parent da8cdcb705
commit 8fd317083b
5 changed files with 692 additions and 137 deletions

View File

@@ -215,6 +215,24 @@ const getSparepartsByMonthlyDb = async (monthly) => {
return result.recordset;
};
const getSparepartsByCustomDb = async (custom) => {
const queryText = `
SELECT *
FROM m_sparepart
WHERE deleted_at IS NULL
AND EXISTS (
SELECT 1
FROM OPENJSON(sparepart_custom)
WHERE value = $1
)
`;
const result = await pool.query(queryText, [custom]);
return result.recordset;
};
module.exports = {
getAllSparepartDb,
getSparepartByIdDb,
@@ -224,5 +242,6 @@ module.exports = {
updateSparepartDb,
deleteSparepartDb,
getSparepartsByYearlyDb,
getSparepartsByMonthlyDb
getSparepartsByMonthlyDb,
getSparepartsByCustomDb
};