diff options
Diffstat (limited to 'lib/projects/service.ts')
| -rw-r--r-- | lib/projects/service.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/projects/service.ts b/lib/projects/service.ts index fe1052f6..acf8b2f5 100644 --- a/lib/projects/service.ts +++ b/lib/projects/service.ts @@ -5,7 +5,7 @@ import db from "@/db/db"; import { unstable_cache } from "@/lib/unstable-cache"; 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 { asc, desc, ilike, inArray, and, gte, lte, not, or, eq } from "drizzle-orm"; import { countProjectLists, selectProjectLists } from "./repository"; import { projects } from "@/db/schema"; import { GetProjectListsSchema } from "./validation"; @@ -84,4 +84,24 @@ export async function getProjectLists(input: GetProjectListsSchema) { tags: ["project-lists"], } )(); - }
\ No newline at end of file + } + +export async function getProjectInfoByProjectCode(projectCode: string) { + const projectInfo = await db.select().from(projects).where(eq(projects.code, projectCode)).limit(1); + + if (!projectInfo || projectInfo.length === 0) { + throw new Error(`프로젝트 코드 "${projectCode}"를 찾을 수 없습니다.`); + } + + const projectInfoForAvl = { + // 프로젝트코드 + projectCode: projectInfo[0].code, + // 프로젝트명 + projectName: projectInfo[0].name, + // 선종 + shipType: projectInfo[0].SKND || undefined, + // H/T 구분 + projectHtDivision: projectInfo[0].type || undefined, + }; + return projectInfoForAvl; +}
\ No newline at end of file |
