From f2363e84af92d784cf1db406cb9d88b890f07361 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Fri, 13 Mar 2026 14:58:38 +0700 Subject: [PATCH] update: room picture upload and hospital logo upload --- src/controllers/hospital_information.ts | 28 ++++++++----------------- src/controllers/room.ts | 24 +++++++-------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/src/controllers/hospital_information.ts b/src/controllers/hospital_information.ts index 15a31c6..88a424d 100644 --- a/src/controllers/hospital_information.ts +++ b/src/controllers/hospital_information.ts @@ -176,18 +176,8 @@ export class HospitalInformationController { format: "binary", description: "Image file (max 1MB, jpg/png/webp)" }, - path: { - type: "string", - description: 'File path', - default: 'uploads/hospital-logo' - }, - application: { - type: "string", - description: 'Application name', - default: 'saude' - } }, - required: ["file", "path", "application"] + required: ["file"] } } } @@ -195,14 +185,14 @@ export class HospitalInformationController { */ try { // Validation schema - const schema = Joi.object().keys({ - path: Joi.string().label('File Path'), - application: Joi.string().label('Application'), - }); + // const schema = Joi.object().keys({ + // path: Joi.string().label('File Path'), + // application: Joi.string().label('Application'), + // }); log.info("body", req.body); - const param: { path: string, application: string } = await schema.validateAsync(req.body); + // const param: { path: string, application: string } = await schema.validateAsync(req.body); // Check if file exists if (!req.files || !req.files.file) { @@ -224,9 +214,9 @@ export class HospitalInformationController { } // Normalize path - param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path; + // param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path; - if (param.path == undefined || param.path == null) param.path = 'uploads/hospital-logo/'; + // if (param.path == undefined || param.path == null) param.path = 'uploads/hospital-logo/'; // Generate unique filename const ext = file.name.split('.'); @@ -241,7 +231,7 @@ export class HospitalInformationController { // md5: file.md5 }; - const folder_path = param.path; + const folder_path ='uploads/hospital-logo/'; const file_path = path.join(folder_path, name); // Create directory if it doesn't exist diff --git a/src/controllers/room.ts b/src/controllers/room.ts index 34ab3c7..f37ff92 100644 --- a/src/controllers/room.ts +++ b/src/controllers/room.ts @@ -318,18 +318,8 @@ export class RoomController { format: "binary", description: "Image file (max 1MB, jpg/png/webp)" }, - path: { - type: "string", - description: 'File path', - default: 'uploads/room-picture' - }, - application: { - type: "string", - description: 'Application name', - default: 'saude' - } }, - required: ["file", "path", "application"] + required: ["file"] } } } @@ -338,13 +328,13 @@ export class RoomController { try { // Validation schema const schema = Joi.object().keys({ - path: Joi.string().label('File Path'), - application: Joi.string().label('Application'), + // path: Joi.string().label('File Path'), + // application: Joi.string().label('Application'), }); log.info("body", req.body); - const param: { path: string, application: string } = await schema.validateAsync(req.body); + // const param: { path: string, application: string } = await schema.validateAsync(req.body); // Check if file exists if (!req.files || !req.files.file) { @@ -366,9 +356,9 @@ export class RoomController { } // Normalize path - param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path; + // param.path = param.path[param.path.length - 1] !== '/' ? param.path + '/' : param.path; - if (param.path == undefined || param.path == null) param.path = 'uploads/room-picture/'; + // if (param.path == undefined || param.path == null) param.path = 'uploads/room-picture/'; // Generate unique filename const ext = file.name.split('.'); @@ -383,7 +373,7 @@ export class RoomController { // md5: file.md5 }; - const folder_path = param.path; + const folder_path = 'uploads/room-picture/'; const file_path = path.join(folder_path, name); // Create directory if it doesn't exist