summaryrefslogtreecommitdiff
path: root/lib/items/service.ts
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-09-18 00:23:40 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-09-18 00:23:40 +0000
commitcf8dac0c6490469dab88a560004b0c07dbd48612 (patch)
treeb9e76061e80d868331e6b4277deecb9086f845f3 /lib/items/service.ts
parente5745fc0268bbb5770bc14a55fd58a0ec30b466e (diff)
(대표님) rfq, 계약, 서명 등
Diffstat (limited to 'lib/items/service.ts')
-rw-r--r--lib/items/service.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/items/service.ts b/lib/items/service.ts
index 1eab3e25..f4865cfa 100644
--- a/lib/items/service.ts
+++ b/lib/items/service.ts
@@ -457,3 +457,35 @@ export async function searchItemsForPQ(query: string): Promise<{ itemCode: strin
return [];
}
}
+
+
+export interface PackageItem {
+ packageCode: string;
+ description: string;
+ smCode: string | null;
+}
+
+export async function getPackagesByProject(projectNo: string): Promise<PackageItem[]> {
+ try {
+ // selectDistinct를 사용하여 중복 제거
+ const result = await db
+ .selectDistinct({
+ packageCode: items.packageCode,
+ description: items.description,
+ smCode: items.smCode,
+ })
+ .from(items)
+ .where(eq(items.ProjectNo, projectNo))
+ .orderBy(items.packageCode);
+
+ // null 값을 처리하고 타입을 정리
+ return result.map(item => ({
+ packageCode: item.packageCode,
+ description: item.description || item.packageCode,
+ smCode: item.smCode || null
+ }));
+ } catch (error) {
+ console.error("Failed to fetch packages:", error);
+ return [];
+ }
+} \ No newline at end of file