Files
service-master-data-revenue/src/model/doctor_item_package.ts
2026-03-17 16:20:03 +07:00

39 lines
1.5 KiB
TypeScript

import { DoctorItemPackage } from "entity";
import { SelectQueryBuilder } from "typeorm";
import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
export class DoctorItemPackageModel {
static async list(filter = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(DoctorItemPackage);
let whereAttr: string[] = [];
let whereVal: any = {};
if (filter && Object.keys(filter).length > 0) {
const filterResult = CommonHelper.handleQueryFilter(filter, "DoctorItemPackage");
whereAttr = [...whereAttr, ...filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
const filterResult = CommonHelper.handleFilter({
filter: JSON.stringify({ any: filterAny.toLowerCase() }),
col_any_eq: [],
col_any_like: ["DoctorItemPackage.name"],
});
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
whereAttr = [...whereAttr, filterResult.whereAttr];
whereVal = { ...whereVal, ...filterResult.whereVal };
}
}
let query = repo
.createQueryBuilder("DoctorItemPackage")
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}