fix: brand api
This commit is contained in:
@@ -13,17 +13,6 @@ const getErrorCodesByBrandIdDb = async (brandId) => {
|
||||
return result.recordset;
|
||||
};
|
||||
|
||||
// Get error code by brand ID and error code
|
||||
const getErrorCodeByBrandIdAndCodeDb = async (brandId, errorCode) => {
|
||||
const queryText = `
|
||||
SELECT
|
||||
a.*
|
||||
FROM brand_code a
|
||||
WHERE a.brand_id = $1 AND a.error_code = $2 AND a.deleted_at IS NULL
|
||||
`;
|
||||
const result = await pool.query(queryText, [brandId, errorCode]);
|
||||
return result.recordset[0];
|
||||
};
|
||||
|
||||
// Create error code for brand
|
||||
const createErrorCodeDb = async (brandId, data) => {
|
||||
@@ -66,29 +55,10 @@ const deleteErrorCodeDb = async (brandId, errorCode, deletedBy) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
// Check if error code exists for brand
|
||||
const checkErrorCodeExistsDb = async (brandId, errorCode, excludeId = null) => {
|
||||
let queryText = `
|
||||
SELECT error_code_id
|
||||
FROM brand_code
|
||||
WHERE brand_id = $1 AND error_code = $2 AND deleted_at IS NULL
|
||||
`;
|
||||
let values = [brandId, errorCode];
|
||||
|
||||
if (excludeId) {
|
||||
queryText += ` AND error_code_id != $3`;
|
||||
values.push(excludeId);
|
||||
}
|
||||
|
||||
const result = await pool.query(queryText, values);
|
||||
return result.recordset.length > 0;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getErrorCodesByBrandIdDb,
|
||||
getErrorCodeByBrandIdAndCodeDb,
|
||||
createErrorCodeDb,
|
||||
updateErrorCodeDb,
|
||||
deleteErrorCodeDb,
|
||||
checkErrorCodeExistsDb,
|
||||
};
|
||||
Reference in New Issue
Block a user