upd: add status column in service

This commit is contained in:
avicenan
2026-02-20 15:50:59 +07:00
parent 9ef6866d73
commit 1bf53b3738
3 changed files with 9 additions and 3 deletions

View File

@ -87,6 +87,7 @@ export class ServiceController {
name: Joi.string().max(256).required().label("Name"), name: Joi.string().max(256).required().label("Name"),
service_type_id: Joi.string().uuid().required().label("Service Type ID"), service_type_id: Joi.string().uuid().required().label("Service Type ID"),
room_ids: Joi.array().items(Joi.string().uuid()).optional().label("Room IDs"), 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); let param: any = await schema.validateAsync(req.body);
@ -106,6 +107,7 @@ export class ServiceController {
service.name = param.name; service.name = param.name;
service.serviceType = serviceType; service.serviceType = serviceType;
service.rooms = rooms; service.rooms = rooms;
service.status = param.status;
service.created_by = req.auth.data.name; service.created_by = req.auth.data.name;
service.updated_by = req.auth.data.name; service.updated_by = req.auth.data.name;
await queryRunner.manager.save(service); await queryRunner.manager.save(service);
@ -170,6 +172,7 @@ export class ServiceController {
name: Joi.string().max(256).required().label("Name"), name: Joi.string().max(256).required().label("Name"),
service_type_id: Joi.string().uuid().required().label("Service Type ID"), service_type_id: Joi.string().uuid().required().label("Service Type ID"),
room_ids: Joi.array().items(Joi.string().uuid()).optional().label("Room IDs"), 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); let param: any = await schema.validateAsync(req.body);
@ -193,6 +196,7 @@ export class ServiceController {
service.name = param.name; service.name = param.name;
service.serviceType = serviceType; service.serviceType = serviceType;
service.rooms = rooms; service.rooms = rooms;
service.status = param.status;
service.updated_by = req.auth.data.name; service.updated_by = req.auth.data.name;
await queryRunner.manager.save(service); await queryRunner.manager.save(service);

View File

@ -9,8 +9,9 @@ export class ServiceModel {
let whereAttr: string[] = []; let whereAttr: string[] = [];
let whereVal: any = {}; let whereVal: any = {};
if (filter && Object.keys(filter).length > 0) { if (filter && Object.keys(filter).length > 0) {
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter).whereAttr]; const filterResult = CommonHelper.handleQueryFilter(filter, "Service");
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal }; whereAttr = [...whereAttr, ...filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
} }
var query = repo.createQueryBuilder("Service"); var query = repo.createQueryBuilder("Service");

View File

@ -123,7 +123,8 @@ const doc = {
service: { service: {
$name: "e.g. ER Registration", $name: "e.g. ER Registration",
$service_type_id: "uuid-string", $service_type_id: "uuid-string",
$room_ids: ["uuid-string"] $room_ids: ["uuid-string"],
$status: { "@enum": ["Y", "N"] }
}, },
servicetodepart: { servicetodepart: {
$room_ids: ["uuid-string"] $room_ids: ["uuid-string"]