repair: detail notif get with error_channel

This commit is contained in:
2025-12-18 16:19:46 +07:00
parent 9f7a73e149
commit 518d6ff427
2 changed files with 10 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ const getNotificationByIdDb = async (id) => {
ON b.plant_sub_section_id = c.plant_sub_section_id ON b.plant_sub_section_id = c.plant_sub_section_id
LEFT JOIN m_device d LEFT JOIN m_device d
ON b.device_id = d.device_id AND d.deleted_at IS NULL ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL
LEFT JOIN m_brands e LEFT JOIN m_brands e
ON d.brand_id = e.brand_id AND d.deleted_at IS NULL ON d.brand_id = e.brand_id AND d.deleted_at IS NULL
@@ -102,8 +102,10 @@ const getAllNotificationDb = async (searchParams = {}) => {
c.type_solution, c.type_solution,
c.path_solution, c.path_solution,
d.device_code,
d.device_name, d.device_name,
d.device_location, d.device_location,
e.brand_name,
COALESCE(d.device_name, '') + ' - ' + COALESCE(b.error_code_name, '') AS device_name_error COALESCE(d.device_name, '') + ' - ' + COALESCE(b.error_code_name, '') AS device_name_error
@@ -116,7 +118,10 @@ const getAllNotificationDb = async (searchParams = {}) => {
ON b.error_code_id = c.error_code_id AND c.deleted_at IS NULL ON b.error_code_id = c.error_code_id AND c.deleted_at IS NULL
LEFT JOIN m_device d LEFT JOIN m_device d
ON b.brand_id = d.brand_id AND d.deleted_at IS NULL ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL
LEFT JOIN m_brands e
ON d.brand_id = e.brand_id AND d.deleted_at IS NULL
WHERE a.deleted_at IS NULL WHERE a.deleted_at IS NULL
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""} ${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}

View File

@@ -7,7 +7,7 @@ const getAllNotificationErrorLogDb = async () => {
b.contact_name, b.contact_name,
b.contact_type b.contact_type
FROM notification_error_log a FROM notification_error_log a
LEFT JOIN contact b ON a.contact_id = b.contact_id LEFT JOIN contact b ON a.contact_phone = b.contact_phone
WHERE a.deleted_at IS NULL WHERE a.deleted_at IS NULL
ORDER BY a.notification_error_log_id DESC ORDER BY a.notification_error_log_id DESC
`; `;
@@ -22,7 +22,7 @@ const getNotificationErrorLogByIdDb = async (id) => {
b.contact_name, b.contact_name,
b.contact_type b.contact_type
FROM notification_error_log a FROM notification_error_log a
LEFT JOIN contact b ON a.contact_id = b.contact_id LEFT JOIN contact b ON a.contact_phone = b.contact_phone
WHERE a.notification_error_log_id = $1 AND a.deleted_at IS NULL WHERE a.notification_error_log_id = $1 AND a.deleted_at IS NULL
`; `;
const result = await pool.query(queryText, [id]); const result = await pool.query(queryText, [id]);
@@ -36,7 +36,7 @@ const getNotificationErrorLogByNotificationErrorIdDb = async (notificationErrorI
b.contact_name, b.contact_name,
b.contact_type b.contact_type
FROM notification_error_log a FROM notification_error_log a
LEFT JOIN contact b ON a.contact_id = b.contact_id LEFT JOIN contact b ON a.contact_phone = b.contact_phone
WHERE a.notification_error_id = $1 AND a.deleted_at IS NULL WHERE a.notification_error_id = $1 AND a.deleted_at IS NULL
ORDER BY a.created_at DESC ORDER BY a.created_at DESC
`; `;