diff options
Diffstat (limited to 'lib/docu-list-rule/code-groups/service.ts')
| -rw-r--r-- | lib/docu-list-rule/code-groups/service.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/docu-list-rule/code-groups/service.ts b/lib/docu-list-rule/code-groups/service.ts index c854f6c9..d9b3b859 100644 --- a/lib/docu-list-rule/code-groups/service.ts +++ b/lib/docu-list-rule/code-groups/service.ts @@ -15,6 +15,7 @@ export async function getCodeGroups(input: { filters: Array<{ id: string; value: string | string[] }> joinOperator: "and" | "or" sort: Array<{ id: string; desc: boolean }> + projectId?: string }) { unstable_noStore() @@ -25,10 +26,15 @@ export async function getCodeGroups(input: { // 검색 조건 (plant 타입 프로젝트만) let whereConditions = sql`${projects.type} = 'plant'` + // 프로젝트 ID 필터링 + if (input.projectId) { + whereConditions = sql`${whereConditions} AND ${codeGroups.projectId} = ${parseInt(input.projectId)}` + } + // 검색어 필터링 if (search) { const searchTerm = `%${search}%` - whereConditions = sql`${projects.type} = 'plant' AND ( + whereConditions = sql`${whereConditions} AND ( ${codeGroups.groupId} ILIKE ${searchTerm} OR ${codeGroups.description} ILIKE ${searchTerm} OR ${codeGroups.codeFormat} ILIKE ${searchTerm} OR |
