room to pharmacy

This commit is contained in:
Muhammad Rayhan Ardiansyah
2026-03-18 09:27:43 +07:00
parent a71238cd7a
commit 690bb135c1
6 changed files with 259 additions and 4 deletions

View File

@ -0,0 +1,25 @@
import { SelectQueryBuilder } from "typeorm";
import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
import { RoomToPharmacy } from "entity";
export class RoomToPharmacyModel {
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(RoomToPharmacy);
let whereAttr: string[] = [];
let whereVal: any = {};
if (filter && Object.keys(filter).length > 0) {
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "room_to_pharmacy").whereAttr];
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "room_to_pharmacy").whereVal };
}
var query = repo.createQueryBuilder("room_to_pharmacy")
.leftJoinAndSelect("room_to_pharmacy.room", "room")
.leftJoinAndSelect("room_to_pharmacy.pharmacy_room", "pharmacy_room");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}