This commit is contained in:
wayanrivan
2026-04-20 10:33:54 +07:00
parent f3ecf8801b
commit fed2e57566
2 changed files with 14 additions and 15 deletions

View File

@ -4,20 +4,19 @@ import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
export class ReferenceRangeModel {
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
static async list(filter: Record<string, any> = {}): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(ReferenceRange);
let whereAttr: string[] = [];
let whereVal: any = {};
const query = repo.createQueryBuilder("ReferenceRange");
if (filter && Object.keys(filter).length > 0) {
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter).whereAttr];
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal };
Object.entries(filter).forEach(([key, value]) => {
if (value !== undefined && value !== null && value !== "") {
query.andWhere(`ReferenceRange.${key} = :${key}`, { [key]: value });
}
});
}
var query = repo.createQueryBuilder("ReferenceRange");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}