feat: implement reminder functionality and enhance notification service with logging

This commit is contained in:
2026-04-29 15:32:03 +07:00
parent 51f4ea2bff
commit a2a64a972f
8 changed files with 443 additions and 9 deletions

View File

@@ -69,6 +69,7 @@ const getDeviceByIdDb = async (id) => {
SELECT
a.*,
b.brand_name,
a.reminder_at AT TIME ZONE 'UTC' AT TIME ZONE 'SE Asia Standard Time' AS reminder_at_local,
COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name
FROM m_device a
LEFT JOIN m_brands b ON a.brand_id = b.brand_id
@@ -124,10 +125,25 @@ const deleteDeviceDb = async (id, deletedBy) => {
return true;
};
const getDeviceReminderChanelDb = async (id) => {
const queryText = `
SELECT
a.*,
b.brand_name,
COALESCE(a.device_code, '') + ' - ' + COALESCE(a.device_name, '') AS device_code_name
FROM m_device a
LEFT JOIN m_brands b ON a.brand_id = b.brand_id
WHERE a.listen_channel_reminder = $1 AND a.deleted_at IS NULL
`;
const result = await pool.query(queryText, [id]);
return result.recordset;
};
module.exports = {
getAllDevicesDb,
getDeviceByIdDb,
createDeviceDb,
updateDeviceDb,
deleteDeviceDb,
getDeviceReminderChanelDb
};