From 36dd60ca6fce7712b35e6d7c1b9602710f442ada Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 28 May 2025 12:26:28 +0000 Subject: (최겸) 기술영업 해양 rfq 개발v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/items-tech/repository.ts | 7 ++++++- lib/items-tech/service.ts | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'lib/items-tech') diff --git a/lib/items-tech/repository.ts b/lib/items-tech/repository.ts index 43e88866..1f4f7933 100644 --- a/lib/items-tech/repository.ts +++ b/lib/items-tech/repository.ts @@ -1,6 +1,6 @@ // src/lib/items/repository.ts import db from "@/db/db"; -import { Item, items } from "@/db/schema/items"; +import { Item, ItemOffshoreTop, ItemOffshoreHull, itemOffshoreHull, itemOffshoreTop, items } from "@/db/schema/items"; import { eq, inArray, @@ -117,3 +117,8 @@ export async function updateItems( export async function findAllItems(): Promise { return db.select().from(items).orderBy(asc(items.itemCode)); } +export async function findAllOffshoreItems(): Promise<(ItemOffshoreHull | ItemOffshoreTop)[]> { + const hullItems = await db.select().from(itemOffshoreHull); + const topItems = await db.select().from(itemOffshoreTop); + return [...hullItems, ...topItems]; +} diff --git a/lib/items-tech/service.ts b/lib/items-tech/service.ts index 62a66aaa..70c664f3 100644 --- a/lib/items-tech/service.ts +++ b/lib/items-tech/service.ts @@ -10,8 +10,9 @@ import { getErrorMessage } from "@/lib/handle-error"; import { asc, desc, ilike, and, or, eq, count, inArray, sql } from "drizzle-orm"; import { GetItemsSchema, UpdateItemSchema, ShipbuildingItemCreateData, TypedItemCreateData, OffshoreTopItemCreateData, OffshoreHullItemCreateData } from "./validations"; -import { Item, items, itemShipbuilding, itemOffshoreTop, itemOffshoreHull } from "@/db/schema/items"; +import { Item, items, itemShipbuilding, itemOffshoreTop, itemOffshoreHull, ItemOffshoreTop, ItemOffshoreHull } from "@/db/schema/items"; import { findAllItems } from "./repository"; +import { findAllOffshoreItems } from "./repository"; /* ----------------------------------------------------- 1) 조회 관련 @@ -1000,3 +1001,10 @@ export async function getAllShipbuildingItems(): Promise { throw new Error("Failed to get items"); } } +export async function getAllOffshoreItems(): Promise<(ItemOffshoreHull | ItemOffshoreTop)[]> { + try { + return await findAllOffshoreItems(); + } catch (err) { + throw new Error("Failed to get items"); + } +} -- cgit v1.2.3