feat(api): add doctor favorite item and package apis

This commit is contained in:
avicenan
2026-03-16 16:41:43 +07:00
parent cd25b9e484
commit 68df2841aa
7 changed files with 557 additions and 4 deletions

View File

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

View File

@ -0,0 +1,29 @@
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 = {}): 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 };
}
let query = repo
.createQueryBuilder("DoctorItemPackage")
.leftJoinAndSelect("DoctorItemPackage.doctor", "Doctor")
.leftJoinAndSelect("DoctorItemPackage.items", "ItemMaster");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}