feat(api)!: replace doctor favorite item endpoints
This commit is contained in:
@ -4,7 +4,7 @@ import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
|
||||
export class DoctorItemPackageModel {
|
||||
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||
static async list(filter = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
|
||||
const repo = OrmHelper.DB.getRepository(DoctorItemPackage);
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
@ -14,11 +14,24 @@ export class DoctorItemPackageModel {
|
||||
whereAttr = [...whereAttr, ...filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
|
||||
const filterResult = CommonHelper.handleFilter({
|
||||
filter: JSON.stringify({ any: filterAny }),
|
||||
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")
|
||||
.leftJoinAndSelect("DoctorItemPackage.doctor", "Doctor")
|
||||
.leftJoinAndSelect("DoctorItemPackage.items", "ItemMaster");
|
||||
.leftJoinAndSelect("DoctorItemPackage.items", "ItemMaster")
|
||||
.leftJoinAndSelect("ItemMaster.generic_name", "GenericName");
|
||||
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
|
||||
Reference in New Issue
Block a user