fix: search any in doctor fav item
This commit is contained in:
@ -37,19 +37,39 @@ export class DoctorItemController {
|
||||
});
|
||||
|
||||
let param: any = await schema.validateAsync(req.query);
|
||||
|
||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||
let filterAny = filter.any && filter.any !== "" ? filter.any : "";
|
||||
|
||||
let filterObj = { ...filter } as any;
|
||||
delete filterObj.any;
|
||||
// filterObj = { ...filterObj};
|
||||
|
||||
|
||||
const repo = OrmHelper.DB.getRepository(ItemMaster);
|
||||
|
||||
let whereAttr: string[] = [];
|
||||
let whereVal: any = {};
|
||||
|
||||
if (filter && Object.keys(filter).length > 0) {
|
||||
const filterResult = CommonHelper.handleQueryFilter(filter, "item_master");
|
||||
if (filterObj && Object.keys(filterObj).length > 0) {
|
||||
const filterResult = CommonHelper.handleQueryFilter(filterObj, "item_master");
|
||||
whereAttr = [...whereAttr, ...filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
|
||||
if (filterAny && filterAny !== "" && filterAny !== null && filterAny !== undefined) {
|
||||
const filterResult = CommonHelper.handleFilter({
|
||||
filter: JSON.stringify({ any: filterAny.toLowerCase() }),
|
||||
col_any_eq: [],
|
||||
col_any_like: ["item_name", "generic_name"],
|
||||
});
|
||||
|
||||
if (filterResult.whereAttr && filterResult.whereAttr !== "") {
|
||||
whereAttr = [...whereAttr, filterResult.whereAttr];
|
||||
whereVal = { ...whereVal, ...filterResult.whereVal };
|
||||
}
|
||||
}
|
||||
|
||||
const orderField = param.order_field || "id";
|
||||
const orderDirection = param.order_direction || "asc";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user