diff options
Diffstat (limited to 'lib/items-tech')
| -rw-r--r-- | lib/items-tech/repository.ts | 7 | ||||
| -rw-r--r-- | lib/items-tech/service.ts | 10 |
2 files changed, 15 insertions, 2 deletions
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<Item[]> { 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<Item[]> { 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");
+ }
+}
|
