update
This commit is contained in:
@ -1,19 +1,19 @@
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import { ItemPrice } from "entity";
|
||||
import { ItemPrice,ItemMaster } from "entity";
|
||||
|
||||
export class ItemPriceModel {
|
||||
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||
const repo = OrmHelper.DB.getRepository(ItemPrice);
|
||||
const repo = OrmHelper.DB.getRepository(ItemMaster);
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
if (filter && Object.keys(filter).length > 0) {
|
||||
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "item_price").whereAttr];
|
||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "item_price").whereVal };
|
||||
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "item_master").whereAttr];
|
||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "item_master").whereVal };
|
||||
}
|
||||
|
||||
var query = repo.createQueryBuilder("item_price").leftJoinAndSelect("item_price.item_master", "item_master");
|
||||
var query = repo.createQueryBuilder("item_master").leftJoinAndSelect("item_master.item_price", "item_price");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user