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/equip-class/service.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'lib/equip-class/service.ts') diff --git a/lib/equip-class/service.ts b/lib/equip-class/service.ts index c35f4fbe..deaacc58 100644 --- a/lib/equip-class/service.ts +++ b/lib/equip-class/service.ts @@ -8,6 +8,7 @@ import { tagClasses } from "@/db/schema/vendorData"; import { asc, desc, ilike, inArray, and, gte, lte, not, or } from "drizzle-orm"; import { GetTagClassesSchema } from "./validation"; import { countTagClassLists, selectTagClassLists } from "./repository"; +import { projects } from "@/db/schema"; export async function getTagClassists(input: GetTagClassesSchema) { @@ -30,7 +31,9 @@ export async function getTagClassists(input: GetTagClassesSchema) { let globalWhere if (input.search) { const s = `%${input.search}%` - globalWhere = or(ilike(tagClasses.code, s), ilike(tagClasses.label, s) + globalWhere = or(ilike(tagClasses.code, s), ilike(tagClasses.label, s), + ilike(projects.name, s), + ilike(projects.code, s) ) // 필요시 여러 칼럼 OR조건 (status, priority, etc) } @@ -49,12 +52,21 @@ export async function getTagClassists(input: GetTagClassesSchema) { const orderBy = - input.sort.length > 0 - ? input.sort.map((item) => - item.desc ? desc(tagClasses[item.id]) : asc(tagClasses[item.id]) - ) - : [asc(tagClasses.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(tagClasses[item.id as keyof typeof tagClasses.$inferSelect]) + : asc(tagClasses[item.id as keyof typeof tagClasses.$inferSelect]); + } + }) + : [asc(tagClasses.createdAt)]; // 트랜잭션 내부에서 Repository 호출 const { data, total } = await db.transaction(async (tx) => { const data = await selectTagClassLists(tx, { -- cgit v1.2.3