update: province, city, subdistrict, ward in hospital information
This commit is contained in:
@ -25,6 +25,10 @@ const hospitalCreateUpdateSchema = {
|
|||||||
address: Joi.string().required().label("Hospital Address"),
|
address: Joi.string().required().label("Hospital Address"),
|
||||||
phone: Joi.string().required().label("Hospital Phone"),
|
phone: Joi.string().required().label("Hospital Phone"),
|
||||||
logo: Joi.string().allow(null, "").label("Hospital Logo"),
|
logo: Joi.string().allow(null, "").label("Hospital Logo"),
|
||||||
|
province: Joi.string().allow("").optional().label("Province Code"),
|
||||||
|
city: Joi.string().allow("").optional().label("City Code"),
|
||||||
|
subdistrict: Joi.string().allow("").optional().label("Subdistrict Code"),
|
||||||
|
ward: Joi.string().allow("").optional().label("Ward Code"),
|
||||||
};
|
};
|
||||||
|
|
||||||
interface FileUploadRequest extends Request {
|
interface FileUploadRequest extends Request {
|
||||||
@ -40,11 +44,13 @@ export class HospitalInformationController {
|
|||||||
#swagger.security = [{ "bearerAuth": [] }]
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const hospital = await OrmHelper.DB
|
const hospital = await OrmHelper.DB.getRepository(HospitalInformation)
|
||||||
.getRepository(HospitalInformation)
|
.createQueryBuilder("HospitalInformation")
|
||||||
.findOne({
|
.leftJoinAndSelect("HospitalInformation.province", "province")
|
||||||
where: {}
|
.leftJoinAndSelect("HospitalInformation.city", "city")
|
||||||
});
|
.leftJoinAndSelect("HospitalInformation.subdistrict", "subdistrict")
|
||||||
|
.leftJoinAndSelect("HospitalInformation.ward", "ward")
|
||||||
|
.getOne();
|
||||||
|
|
||||||
if (!hospital) return ReturnHelper.errorResponse(res, 404, 404, Language.lang.failed_view, "Hospital not found");
|
if (!hospital) return ReturnHelper.errorResponse(res, 404, 404, Language.lang.failed_view, "Hospital not found");
|
||||||
|
|
||||||
@ -59,7 +65,11 @@ export class HospitalInformationController {
|
|||||||
address: hospital.address,
|
address: hospital.address,
|
||||||
phone: hospital.phone,
|
phone: hospital.phone,
|
||||||
logo: hospitallogo,
|
logo: hospitallogo,
|
||||||
file: hospital.logo
|
file: hospital.logo,
|
||||||
|
province: hospital.province,
|
||||||
|
city: hospital.city,
|
||||||
|
subdistrict: hospital.subdistrict,
|
||||||
|
ward: hospital.ward
|
||||||
};
|
};
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, result);
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, result);
|
||||||
@ -97,6 +107,10 @@ export class HospitalInformationController {
|
|||||||
hospitalinformation.address = param.address;
|
hospitalinformation.address = param.address;
|
||||||
hospitalinformation.phone = param.phone;
|
hospitalinformation.phone = param.phone;
|
||||||
hospitalinformation.logo = param.logo;
|
hospitalinformation.logo = param.logo;
|
||||||
|
hospitalinformation.province = param.province;
|
||||||
|
hospitalinformation.city = param.city;
|
||||||
|
hospitalinformation.subdistrict = param.subdistrict;
|
||||||
|
hospitalinformation.ward = param.ward;
|
||||||
hospitalinformation.created_by = req.auth?.data.name;
|
hospitalinformation.created_by = req.auth?.data.name;
|
||||||
hospitalinformation.updated_by = req.auth?.data.name;
|
hospitalinformation.updated_by = req.auth?.data.name;
|
||||||
await queryRunner.manager.save(hospitalinformation);
|
await queryRunner.manager.save(hospitalinformation);
|
||||||
@ -148,6 +162,10 @@ export class HospitalInformationController {
|
|||||||
hospitalinformation.address = param.address;
|
hospitalinformation.address = param.address;
|
||||||
hospitalinformation.phone = param.phone;
|
hospitalinformation.phone = param.phone;
|
||||||
hospitalinformation.logo = param.logo ? param.logo : hospital.logo;
|
hospitalinformation.logo = param.logo ? param.logo : hospital.logo;
|
||||||
|
hospitalinformation.province = param.province;
|
||||||
|
hospitalinformation.city = param.city;
|
||||||
|
hospitalinformation.subdistrict = param.subdistrict;
|
||||||
|
hospitalinformation.ward = param.ward;
|
||||||
hospitalinformation.updated_by = req.auth?.data.name;
|
hospitalinformation.updated_by = req.auth?.data.name;
|
||||||
await queryRunner.manager.save(hospitalinformation);
|
await queryRunner.manager.save(hospitalinformation);
|
||||||
|
|
||||||
|
|||||||
@ -241,6 +241,10 @@ const doc = {
|
|||||||
$address: "Hospital Address",
|
$address: "Hospital Address",
|
||||||
$phone: "Hospital Phone",
|
$phone: "Hospital Phone",
|
||||||
$logo: "Hospital Logo",
|
$logo: "Hospital Logo",
|
||||||
|
$province: "province code",
|
||||||
|
$city: "city code",
|
||||||
|
$subdistrict: "subdistrict code",
|
||||||
|
$ward: "ward code",
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
$file_name: "File Name",
|
$file_name: "File Name",
|
||||||
|
|||||||
Reference in New Issue
Block a user