feat(api): add doctor favorite item and package apis
This commit is contained in:
29
src/model/doctor_favorite_item.ts
Normal file
29
src/model/doctor_favorite_item.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
29
src/model/doctor_item_package.ts
Normal file
29
src/model/doctor_item_package.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user