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"),
|
||||
phone: Joi.string().required().label("Hospital Phone"),
|
||||
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 {
|
||||
@ -40,11 +44,13 @@ export class HospitalInformationController {
|
||||
#swagger.security = [{ "bearerAuth": [] }]
|
||||
*/
|
||||
try {
|
||||
const hospital = await OrmHelper.DB
|
||||
.getRepository(HospitalInformation)
|
||||
.findOne({
|
||||
where: {}
|
||||
});
|
||||
const hospital = await OrmHelper.DB.getRepository(HospitalInformation)
|
||||
.createQueryBuilder("HospitalInformation")
|
||||
.leftJoinAndSelect("HospitalInformation.province", "province")
|
||||
.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");
|
||||
|
||||
@ -59,7 +65,11 @@ export class HospitalInformationController {
|
||||
address: hospital.address,
|
||||
phone: hospital.phone,
|
||||
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);
|
||||
@ -97,6 +107,10 @@ export class HospitalInformationController {
|
||||
hospitalinformation.address = param.address;
|
||||
hospitalinformation.phone = param.phone;
|
||||
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.updated_by = req.auth?.data.name;
|
||||
await queryRunner.manager.save(hospitalinformation);
|
||||
@ -148,6 +162,10 @@ export class HospitalInformationController {
|
||||
hospitalinformation.address = param.address;
|
||||
hospitalinformation.phone = param.phone;
|
||||
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;
|
||||
await queryRunner.manager.save(hospitalinformation);
|
||||
|
||||
|
||||
@ -241,6 +241,10 @@ const doc = {
|
||||
$address: "Hospital Address",
|
||||
$phone: "Hospital Phone",
|
||||
$logo: "Hospital Logo",
|
||||
$province: "province code",
|
||||
$city: "city code",
|
||||
$subdistrict: "subdistrict code",
|
||||
$ward: "ward code",
|
||||
},
|
||||
files: {
|
||||
$file_name: "File Name",
|
||||
|
||||
Reference in New Issue
Block a user