From 9ceed79cf32c896f8a998399bf1b296506b2cd4a Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 8 Apr 2025 03:08:19 +0000 Subject: 로그인 및 미들웨어 처리. 구조 변경 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/form-list/service.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'lib/form-list/service.ts') diff --git a/lib/form-list/service.ts b/lib/form-list/service.ts index 64156cf4..310930be 100644 --- a/lib/form-list/service.ts +++ b/lib/form-list/service.ts @@ -8,6 +8,7 @@ import { filterColumns } from "@/lib/filter-columns"; import { tagTypeClassFormMappings } from "@/db/schema/vendorData"; import { asc, desc, ilike, inArray, and, gte, lte, not, or } from "drizzle-orm"; import { countFormLists, selectFormLists } from "./repository"; +import { projects } from "@/db/schema"; export async function getFormLists(input: GetFormListsSchema) { @@ -31,7 +32,9 @@ export async function getFormLists(input: GetFormListsSchema) { if (input.search) { const s = `%${input.search}%` globalWhere = or(ilike(tagTypeClassFormMappings.formCode, s), ilike(tagTypeClassFormMappings.formName, s) - , ilike(tagTypeClassFormMappings.tagTypeLabel, s) , ilike(tagTypeClassFormMappings.classLabel, s) + , ilike(tagTypeClassFormMappings.tagTypeLabel, s) , ilike(tagTypeClassFormMappings.classLabel, s), + ilike(projects.name, s), + ilike(projects.code, s), ) // 필요시 여러 칼럼 OR조건 (status, priority, etc) } @@ -48,12 +51,21 @@ export async function getFormLists(input: GetFormListsSchema) { const orderBy = - input.sort.length > 0 - ? input.sort.map((item) => - item.desc ? desc(tagTypeClassFormMappings[item.id]) : asc(tagTypeClassFormMappings[item.id]) - ) - : [asc(tagTypeClassFormMappings.createdAt)]; - + input.sort.length > 0 + ? input.sort.map((item) => { + // 프로젝트 관련 필드 정렬 처리 + if (item.id === 'projectCode') { + return item.desc ? desc(projects.code) : asc(projects.code); + } else if (item.id === 'projectName') { + return item.desc ? desc(projects.name) : asc(projects.name); + } else { + // 기존 필드 정렬 + return item.desc + ? desc(tagTypeClassFormMappings[item.id]) + : asc(tagTypeClassFormMappings[item.id]); + } + }) + : [asc(tagTypeClassFormMappings.createdAt)]; // 트랜잭션 내부에서 Repository 호출 const { data, total } = await db.transaction(async (tx) => { const data = await selectFormLists(tx, { @@ -78,7 +90,7 @@ export async function getFormLists(input: GetFormListsSchema) { [JSON.stringify(input)], // 캐싱 키 { revalidate: 3600, - tags: ["form-lists"], // revalidateTag("items") 호출 시 무효화 + tags: ["form-lists"], } )(); } \ No newline at end of file -- cgit v1.2.3