update: load picture for hospital logo
This commit is contained in:
@ -41,16 +41,28 @@ export class HospitalInformationController {
|
|||||||
#swagger.security = [{ "bearerAuth": [] }]
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const hospital = await OrmHelper.DB.getRepository(HospitalInformation).findOne({
|
const hospital = await OrmHelper.DB
|
||||||
where: {}
|
.getRepository(HospitalInformation)
|
||||||
});
|
.findOne({
|
||||||
|
where: {}
|
||||||
|
});
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_insert, hospital);
|
if (!hospital) return ReturnHelper.errorResponse(res, 404, 404, Language.lang.failed_view, "Hospital not found");
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
id: hospital.id,
|
||||||
|
name: hospital.name,
|
||||||
|
address: hospital.address,
|
||||||
|
phone: hospital.phone,
|
||||||
|
logo: 'http://his.shiblysolution.id:3011/service-master-data/uploads/hospital-logo/' + hospital.logo
|
||||||
|
};
|
||||||
|
|
||||||
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, result);
|
||||||
|
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
const err = e as Error;
|
const err = e as Error;
|
||||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
return ReturnHelper.errorResponse(res,400,401,Language.lang.failed_view,err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,13 +228,13 @@ export class HospitalInformationController {
|
|||||||
const ext = file.name.split('.');
|
const ext = file.name.split('.');
|
||||||
const name = uuidv4() + '.' + ext[ext.length - 1];
|
const name = uuidv4() + '.' + ext[ext.length - 1];
|
||||||
|
|
||||||
const result: { url: string, path: string, file: string, mime: string, size: number, md5: string } = {
|
const result: { file: string } = {
|
||||||
url: "",
|
// url: "",
|
||||||
path: "",
|
// path: "",
|
||||||
file: "",
|
file: "",
|
||||||
mime: file.mimetype,
|
// mime: file.mimetype,
|
||||||
size: file.size,
|
// size: file.size,
|
||||||
md5: file.md5
|
// md5: file.md5
|
||||||
};
|
};
|
||||||
|
|
||||||
const folder_path = param.path;
|
const folder_path = param.path;
|
||||||
@ -236,9 +248,9 @@ export class HospitalInformationController {
|
|||||||
// Move file to destination
|
// Move file to destination
|
||||||
await file.mv(file_path);
|
await file.mv(file_path);
|
||||||
|
|
||||||
result.path = param.path[param.path.length - 1] === '/' ? param.path.substring(0, param.path.length - 1) : param.path;
|
// result.path = param.path[param.path.length - 1] === '/' ? param.path.substring(0, param.path.length - 1) : param.path;
|
||||||
result.file = name;
|
result.file = name;
|
||||||
result.url = `${result.path}/${name}`; // Generate URL
|
// result.url = `${result.path}/${name}`; // Generate URL
|
||||||
|
|
||||||
log.info(`File uploaded successfully: ${file_path}`);
|
log.info(`File uploaded successfully: ${file_path}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user