Ajout de la gestion des chemins d'images et amélioration des messages de log dans plusieurs modules
This commit is contained in:
@@ -7,13 +7,14 @@ async function uploadMeasureImage(image, projectId, orderId) {
|
||||
const imagesDir = storageManager.createFolder(path.join(projectDir, 'images'));
|
||||
var imagePath = path.join(imagesDir, `${orderId}.jpg`);
|
||||
storageManager.saveFile(imagePath, image.buffer);
|
||||
|
||||
console.log("[FILE] uploadMeasureImage - Image saved to: " + imagePath);
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
async function getMeasureImage(projectId, orderId) {
|
||||
const projectPath = `${projectId}`;
|
||||
const imagePath = `${projectPath}/${orderId}.jpg`;
|
||||
console.log("[FILE] getMeasureImage - Image path: " + imagePath);
|
||||
return storageManager.getFile(imagePath);
|
||||
}
|
||||
|
||||
@@ -21,6 +22,7 @@ async function getNextOrderId(projectId) {
|
||||
const query = 'SELECT MAX(order_id) FROM public.measurements WHERE project_id = $1';
|
||||
const values = [projectId];
|
||||
const res = await db.query(query, values);
|
||||
console.log("[DB] getNextOrderId - Max order_id: " + res.rows[0].max);
|
||||
return res.rows[0].max + 1;
|
||||
}
|
||||
|
||||
@@ -73,6 +75,13 @@ async function deleteMeasurement(id) {
|
||||
return res.rows[0];
|
||||
}
|
||||
|
||||
async function getPathFromIds(projectId, orderId) {
|
||||
const query = 'SELECT path FROM public.measurements WHERE project_id = $1 AND order_id = $2';
|
||||
const values = [projectId, orderId];
|
||||
const res = await db.query(query, values);
|
||||
return res.rows[0].path;
|
||||
}
|
||||
|
||||
export {
|
||||
uploadMeasureImage,
|
||||
addMeasureToProject,
|
||||
@@ -83,5 +92,6 @@ export {
|
||||
deleteMeasurement,
|
||||
getMeasureImage,
|
||||
getMeasurementById,
|
||||
updateMeasurementById
|
||||
updateMeasurementById,
|
||||
getPathFromIds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user