foster care history done
This commit is contained in:
37
src/model/fostercarehistory.ts
Normal file
37
src/model/fostercarehistory.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { FosterCareHistory } from "entity";
|
||||
import { SelectQueryBuilder } from "typeorm";
|
||||
import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
|
||||
export class FosterCareHistoryModel {
|
||||
static async list(filterObj = {}, filterAny: string = ""): Promise<SelectQueryBuilder<any>> {
|
||||
const repo = OrmHelper.DB.getRepository(FosterCareHistory);
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
if (filterObj && Object.keys(filterObj).length > 0) {
|
||||
const filterResult = CommonHelper.handleQueryFilter(filterObj);
|
||||
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: ["foster_care_history_code", "foster_care_history_name", "foster_care_history_type"],
|
||||
});
|
||||
|
||||
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
|
||||
whereAttr = [...whereAttr, filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
}
|
||||
|
||||
var query = repo.createQueryBuilder("FosterCareHistory");
|
||||
if (whereAttr.length != 0) {
|
||||
query = query.where(whereAttr.join(" and "), whereVal);
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user