diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-27 12:06:26 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-08-27 12:06:26 +0000 |
| commit | 7548e2ad6948f1c6aa102fcac408bc6c9c0f9796 (patch) | |
| tree | 8e66703ec821888ad51dcc242a508813a027bf71 /lib/basic-contract/repository.ts | |
| parent | 7eac558470ef179dad626a8e82db5784fe86a556 (diff) | |
(대표님, 최겸) 기본계약, 입찰, 파일라우트, 계약서명라우트, 인포메이션, 메뉴설정, PQ(메일템플릿 관련)
Diffstat (limited to 'lib/basic-contract/repository.ts')
| -rw-r--r-- | lib/basic-contract/repository.ts | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/lib/basic-contract/repository.ts b/lib/basic-contract/repository.ts index aab70106..237402d0 100644 --- a/lib/basic-contract/repository.ts +++ b/lib/basic-contract/repository.ts @@ -1,7 +1,7 @@ "use server";
import { asc, count,inArray ,eq} from "drizzle-orm";
-import { basicContractTemplates, basicContractView, type BasicContractTemplate } from "@/db/schema";
+import { basicContractTemplates, basicContractView,basicContractTemplateStatsView, type BasicContractTemplate } from "@/db/schema";
import { PgTransaction } from "drizzle-orm/pg-core";
import db from "@/db/db";
@@ -39,6 +39,47 @@ export async function selectBasicContracts( return tx
.select()
+ .from(basicContractTemplateStatsView)
+ .where(where || undefined)
+ .orderBy(...(orderBy || [asc(basicContractTemplateStatsView.lastActivityDate)]))
+ .offset(offset || 0)
+ .limit(limit || 50);
+}
+
+export async function selectBasicContractsVendor(
+ tx: PgTransaction<any, any, any>,
+ options: {
+ where?: any;
+ orderBy?: any[];
+ offset?: number;
+ limit?: number;
+ }
+) {
+ const { where, orderBy, offset, limit } = options;
+
+ return tx
+ .select()
+ .from(basicContractView)
+ .where(where || undefined)
+ .orderBy(...(orderBy || [asc(basicContractView.createdAt)]))
+ .offset(offset || 0)
+ .limit(limit || 50);
+}
+
+
+export async function selectBasicContractsById(
+ tx: PgTransaction<any, any, any>,
+ options: {
+ where?: any;
+ orderBy?: any[];
+ offset?: number;
+ limit?: number;
+ }
+) {
+ const { where, orderBy, offset, limit } = options;
+
+ return tx
+ .select()
.from(basicContractView)
.where(where || undefined)
.orderBy(...(orderBy || [asc(basicContractView.createdAt)]))
@@ -65,12 +106,35 @@ export async function countBasicContracts( ) {
const result = await tx
.select({ count: count() })
+ .from(basicContractTemplateStatsView)
+ .where(where || undefined);
+
+ return result[0]?.count || 0;
+}
+
+export async function countBasicContractsVendor(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+) {
+ const result = await tx
+ .select({ count: count() })
.from(basicContractView)
.where(where || undefined);
return result[0]?.count || 0;
}
+export async function countBasicContractsById(
+ tx: PgTransaction<any, any, any>,
+ where?: any
+) {
+ const result = await tx
+ .select({ count: count() })
+ .from(basicContractView)
+ .where(where || undefined);
+
+ return result[0]?.count || 0;
+}
// 템플릿 생성
export async function insertBasicContractTemplate(
|
