diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-03 02:47:09 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-03 02:47:09 +0000 |
| commit | 6f22fc9ebc8d175041aa18cf0986592e57d03f63 (patch) | |
| tree | a1f511d42cf6eaeb18ab41a61374731166886ecd /lib/tech-vendor-possible-items/repository.ts | |
| parent | 78d76dd27148a8b74a99b4ee984fd800fd92d00d (diff) | |
(최겸) 기술영업 벤더별 아이템 조회 기능 추가
Diffstat (limited to 'lib/tech-vendor-possible-items/repository.ts')
| -rw-r--r-- | lib/tech-vendor-possible-items/repository.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/tech-vendor-possible-items/repository.ts b/lib/tech-vendor-possible-items/repository.ts new file mode 100644 index 00000000..b2588395 --- /dev/null +++ b/lib/tech-vendor-possible-items/repository.ts @@ -0,0 +1,47 @@ +import { eq, desc, count } from "drizzle-orm";
+import {
+ techVendors,
+ techVendorPossibleItems
+} from "@/db/schema/techVendors";
+
+/**
+ * 기술영업 벤더 가능 아이템 목록 조회 (조인 포함)
+ */
+export async function selectTechVendorPossibleItemsWithJoin(
+ tx: any,
+ where: any,
+ orderBy: any[],
+ offset: number,
+ limit: number
+) {
+ return await tx
+ .select({
+ id: techVendorPossibleItems.id,
+ vendorId: techVendorPossibleItems.vendorId,
+ vendorCode: techVendors.vendorCode,
+ vendorName: techVendors.vendorName,
+ techVendorType: techVendors.techVendorType,
+ itemCode: techVendorPossibleItems.itemCode,
+ createdAt: techVendorPossibleItems.createdAt,
+ updatedAt: techVendorPossibleItems.updatedAt,
+ })
+ .from(techVendorPossibleItems)
+ .innerJoin(techVendors, eq(techVendorPossibleItems.vendorId, techVendors.id))
+ .where(where)
+ .orderBy(...(orderBy || [desc(techVendorPossibleItems.createdAt)]))
+ .limit(limit)
+ .offset(offset);
+}
+
+/**
+ * 기술영업 벤더 가능 아이템 총 개수 조회 (조인 포함)
+ */
+export async function countTechVendorPossibleItemsWithJoin(tx: any, where?: any) {
+ const [result] = await tx
+ .select({ count: count() })
+ .from(techVendorPossibleItems)
+ .innerJoin(techVendors, eq(techVendorPossibleItems.vendorId, techVendors.id))
+ .where(where);
+
+ return result.count;
+}
\ No newline at end of file |
