repair: brand device connect to sparepart

This commit is contained in:
2025-12-01 10:35:25 +07:00
parent 462cf6e94b
commit 920b24bfd2
4 changed files with 75 additions and 44 deletions

View File

@@ -147,9 +147,39 @@ const deleteSparepartDb = async (id, deletedBy) => {
return true;
};
// Get multiple spareparts by IDs
const getSparepartsByIdsDb = async (sparepartIds) => {
if (!sparepartIds || sparepartIds.length === 0) return [];
const placeholders = sparepartIds.map((_, index) => `$${index + 1}`).join(', ');
const queryText = `
SELECT
sparepart_id,
sparepart_name,
sparepart_code,
sparepart_description,
sparepart_model,
sparepart_foto,
sparepart_item_type,
sparepart_qty,
sparepart_unit,
sparepart_merk,
sparepart_stok,
created_at,
updated_at
FROM m_sparepart
WHERE sparepart_id IN (${placeholders})
AND deleted_at IS NULL
`;
const result = await pool.query(queryText, sparepartIds);
return result.recordset;
};
module.exports = {
getAllSparepartDb,
getSparepartByIdDb,
getSparepartsByIdsDb,
checkSparepartNameExistsDb,
createSparepartDb,
updateSparepartDb,