From d1c839b9312a3b27803b1fec280bf72da9d56ee6 Mon Sep 17 00:00:00 2001 From: avicenan Date: Tue, 26 May 2026 17:27:19 +0900 Subject: [PATCH] fix(settings): service --- src/controllers/service.ts | 6 +++++- src/model/service.ts | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/controllers/service.ts b/src/controllers/service.ts index 5dae172..8c2c290 100644 --- a/src/controllers/service.ts +++ b/src/controllers/service.ts @@ -43,8 +43,12 @@ export class ServiceController { let param: Paging = await schema.validateAsync(req.query); let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {}; + let filterAny = filter.any && filter.any !== "" ? filter.any : ""; - var query = await ServiceModel.list(filter); + let filterObj = { ...filter } as any; + delete filterObj.any; + + var query = await ServiceModel.list(filterObj, filterAny); const offset = (param.page - 1) * param.limit; let limit = param.limit; diff --git a/src/model/service.ts b/src/model/service.ts index d265c02..c2becfd 100644 --- a/src/model/service.ts +++ b/src/model/service.ts @@ -4,16 +4,29 @@ import CommonHelper from "../helpers/common"; import { OrmHelper } from "../helpers/orm"; export class ServiceModel { - static async list(filter = {}): Promise> { + static async list(filterObj = {}, filterAny: string = ""): Promise> { const repo = OrmHelper.DB.getRepository(Service); let whereAttr: string[] = []; let whereVal: any = {}; - if (filter && Object.keys(filter).length > 0) { - const filterResult = CommonHelper.handleQueryFilter(filter, "Service"); + if (filterObj && Object.keys(filterObj).length > 0) { + const filterResult = CommonHelper.handleQueryFilter(filterObj, "Service"); 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: ["name", "serviceType.name"], + }); + + if (filterResult.whereAttr && filterResult.whereAttr !== "") { + whereAttr = [...whereAttr, filterResult.whereAttr]; + whereVal = { ...whereVal, ...filterResult.whereVal }; + } + } + var query = repo.createQueryBuilder("Service"); if (whereAttr.length != 0) { query = query.where(whereAttr.join(" and "), whereVal);