diff --git a/src/controllers/service.ts b/src/controllers/service.ts index c9dc7bb..c5a89ac 100644 --- a/src/controllers/service.ts +++ b/src/controllers/service.ts @@ -87,6 +87,7 @@ export class ServiceController { name: Joi.string().max(256).required().label("Name"), service_type_id: Joi.string().uuid().required().label("Service Type ID"), room_ids: Joi.array().items(Joi.string().uuid()).optional().label("Room IDs"), + status: Joi.string().required().label("Status"), }); let param: any = await schema.validateAsync(req.body); @@ -106,6 +107,7 @@ export class ServiceController { service.name = param.name; service.serviceType = serviceType; service.rooms = rooms; + service.status = param.status; service.created_by = req.auth.data.name; service.updated_by = req.auth.data.name; await queryRunner.manager.save(service); @@ -170,6 +172,7 @@ export class ServiceController { name: Joi.string().max(256).required().label("Name"), service_type_id: Joi.string().uuid().required().label("Service Type ID"), room_ids: Joi.array().items(Joi.string().uuid()).optional().label("Room IDs"), + status: Joi.string().required().label("Status"), }); let param: any = await schema.validateAsync(req.body); @@ -193,6 +196,7 @@ export class ServiceController { service.name = param.name; service.serviceType = serviceType; service.rooms = rooms; + service.status = param.status; service.updated_by = req.auth.data.name; await queryRunner.manager.save(service); diff --git a/src/model/service.ts b/src/model/service.ts index c5c57a5..d265c02 100644 --- a/src/model/service.ts +++ b/src/model/service.ts @@ -9,8 +9,9 @@ export class ServiceModel { let whereAttr: string[] = []; let whereVal: any = {}; if (filter && Object.keys(filter).length > 0) { - whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter).whereAttr]; - whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal }; + const filterResult = CommonHelper.handleQueryFilter(filter, "Service"); + whereAttr = [...whereAttr, ...filterResult.whereAttr]; + whereVal = { ...whereVal, ...filterResult.whereVal }; } var query = repo.createQueryBuilder("Service"); diff --git a/src/swagger/builder.js b/src/swagger/builder.js index ded6f49..ed06e53 100644 --- a/src/swagger/builder.js +++ b/src/swagger/builder.js @@ -123,7 +123,8 @@ const doc = { service: { $name: "e.g. ER Registration", $service_type_id: "uuid-string", - $room_ids: ["uuid-string"] + $room_ids: ["uuid-string"], + $status: { "@enum": ["Y", "N"] } }, servicetodepart: { $room_ids: ["uuid-string"]