summaryrefslogtreecommitdiff
path: root/lib/projects/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/projects/service.ts')
-rw-r--r--lib/projects/service.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/projects/service.ts b/lib/projects/service.ts
index 3f562e20..4685fce4 100644
--- a/lib/projects/service.ts
+++ b/lib/projects/service.ts
@@ -112,4 +112,27 @@ export async function getAllProjectInfoByProjectCode(projectCode: string) {
.from(projects)
.where(eq(projects.code, projectCode))
.limit(1);
+}
+
+/**
+ * projectId로 프로젝트 코드를 가져오는 함수
+ * @param projectId - 프로젝트 ID
+ * @returns 프로젝트 코드 또는 null
+ */
+export async function getProjectCode(projectId: number): Promise<string | null> {
+ try {
+ const project = await db.project.findUnique({
+ where: {
+ id: projectId,
+ },
+ select: {
+ code: true,
+ },
+ })
+
+ return project?.code || null
+ } catch (error) {
+ console.error("Error fetching project code:", error)
+ return null
+ }
} \ No newline at end of file