This commit is contained in:
2026-04-16 15:24:25 +07:00
parent 87e48a8165
commit 6424f645e4
3 changed files with 46 additions and 44 deletions

View File

@ -52,8 +52,19 @@ export class ScheduleController {
order_direction: "asc" | "desc";
} = await schema.validateAsync(req.query);
const filterObj = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
const filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
const filterAny = filter.any && filter.any !== "" ? String(filter.any) : "";
const filterObj = { ...filter } as any;
delete filterObj.any;
const query = await ScheduleModel.listSeries(filterObj);
if (filterAny !== "") {
const anyVal = filterAny.includes("%") ? filterAny : `%${filterAny}%`;
query.andWhere(
"(ScheduleSeries.title ILIKE :any OR Room.room ILIKE :any OR Room.code ILIKE :any OR Doctor.name ILIKE :any OR Doctor.username ILIKE :any)",
{ any: anyVal }
);
}
const orderDirection = param.order_direction.toUpperCase() as "ASC" | "DESC";
const offset = (param.page - 1) * param.limit;