repair: notification error sparepart

This commit is contained in:
2025-12-04 16:07:04 +07:00
parent 198346ff0b
commit 1d3de9ae41

View File

@@ -1,6 +1,34 @@
const pool = require("../config");
const insertNotificationErrorSparepartDb = async () => {
const insertQuery = `
INSERT INTO notification_error_sparepart (
notification_error_id,
brand_sparepart_id
)
SELECT
ne.notification_error_id,
bs.brand_sparepart_id
FROM notification_error ne
INNER JOIN brand_sparepart bs
ON ne.error_code_id = bs.error_code_id
LEFT JOIN notification_error_sparepart nes
ON nes.notification_error_id = ne.notification_error_id
AND nes.brand_sparepart_id = bs.brand_sparepart_id
AND nes.deleted_at IS NULL
WHERE ne.deleted_at IS NULL
AND nes.notification_error_sparepart_id IS NULL;
`;
await pool.query(insertQuery);
};
const getAllNotificationErrorSparepartDb = async (searchParams = {}) => {
await insertNotificationErrorSparepartDb();
let queryParams = [];
if (searchParams.limit) {