diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-07 17:39:36 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-07 17:39:36 +0900 |
| commit | 1363913352722a03e051b15297f72bf16d80106f (patch) | |
| tree | 1f4b1228ff171bda515deb95dcdde1f4484ced8e /lib/vendor-document-list/service.ts | |
| parent | ba8cd44a0ed2c613a5f2cee06bfc9bd0f61f21c7 (diff) | |
(김준회) 돌체 업로드 MIME 타입 검증 문제 확장자로 처리
Diffstat (limited to 'lib/vendor-document-list/service.ts')
| -rw-r--r-- | lib/vendor-document-list/service.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/vendor-document-list/service.ts b/lib/vendor-document-list/service.ts index 76bdac49..502d9352 100644 --- a/lib/vendor-document-list/service.ts +++ b/lib/vendor-document-list/service.ts @@ -4,6 +4,7 @@ import { eq, SQL } from "drizzle-orm" import db from "@/db/db" import { documents, documentStagesView, issueStages } from "@/db/schema/vendorDocu" import { contracts } from "@/db/schema" +import { projects } from "@/db/schema/projects" import { GetVendorDcoumentsSchema } from "./validations" import { unstable_cache } from "@/lib/unstable-cache"; import { filterColumns } from "@/lib/filter-columns"; @@ -323,4 +324,39 @@ export async function getProjectIdsByVendor(vendorId: number): Promise<number[]> console.error('Error fetching contract IDs by vendor:', error) return [] } +} + +/** + * 프로젝트 ID 배열로 프로젝트 정보를 조회하는 서버 액션 + * @param projectIds - 프로젝트 ID 배열 + * @returns 프로젝트 정보 배열 [{ id, code, name }] + */ +export async function getProjectsByIds(projectIds: number[]): Promise<Array<{ id: number; code: string; name: string }>> { + try { + if (projectIds.length === 0) { + return [] + } + + // null 값 제거 + const validProjectIds = projectIds.filter((id): id is number => id !== null && !isNaN(id)) + + if (validProjectIds.length === 0) { + return [] + } + + const projectsData = await db + .select({ + id: projects.id, + code: projects.code, + name: projects.name, + }) + .from(projects) + .where(inArray(projects.id, validProjectIds)) + .orderBy(projects.code) + + return projectsData + } catch (error) { + console.error('프로젝트 정보 조회 중 오류:', error) + return [] + } }
\ No newline at end of file |
