update: load picture for hospital logo
This commit is contained in:
@ -41,16 +41,28 @@ export class HospitalInformationController {
|
||||
#swagger.security = [{ "bearerAuth": [] }]
|
||||
*/
|
||||
try {
|
||||
const hospital = await OrmHelper.DB.getRepository(HospitalInformation).findOne({
|
||||
where: {}
|
||||
});
|
||||
const hospital = await OrmHelper.DB
|
||||
.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) {
|
||||
log.error(e);
|
||||
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 name = uuidv4() + '.' + ext[ext.length - 1];
|
||||
|
||||
const result: { url: string, path: string, file: string, mime: string, size: number, md5: string } = {
|
||||
url: "",
|
||||
path: "",
|
||||
const result: { file: string } = {
|
||||
// url: "",
|
||||
// path: "",
|
||||
file: "",
|
||||
mime: file.mimetype,
|
||||
size: file.size,
|
||||
md5: file.md5
|
||||
// mime: file.mimetype,
|
||||
// size: file.size,
|
||||
// md5: file.md5
|
||||
};
|
||||
|
||||
const folder_path = param.path;
|
||||
@ -236,9 +248,9 @@ export class HospitalInformationController {
|
||||
// Move file to destination
|
||||
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.url = `${result.path}/${name}`; // Generate URL
|
||||
// result.url = `${result.path}/${name}`; // Generate URL
|
||||
|
||||
log.info(`File uploaded successfully: ${file_path}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user