From 5b6313f16f508882a0ea67716b7dbaa1c6967f04 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 30 Jun 2025 08:28:13 +0000 Subject: (대표님) 20250630 16시 - 유저 도메인별 라우터 분리와 보안성검토 대응 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/admin-users/repository.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/admin-users/repository.ts') diff --git a/lib/admin-users/repository.ts b/lib/admin-users/repository.ts index aff2da28..63e98b4e 100644 --- a/lib/admin-users/repository.ts +++ b/lib/admin-users/repository.ts @@ -49,6 +49,30 @@ export async function selectUsersWithCompanyAndRoles( return rows } +export async function selectUsers( + tx: PgTransaction, + params: { + where?: any + orderBy?: (ReturnType | ReturnType)[] + offset?: number + limit?: number + } +) { + const { where, orderBy, offset = 0, limit = 10 } = params + + // 1) 쿼리 빌더 생성 + const queryBuilder = tx + .select() + .from(users) + .where(where) + .orderBy(...(orderBy ?? [])) + .offset(offset) + .limit(limit) + + const rows = await queryBuilder + return rows +} + /** 총 개수 count */ export async function countUsers( @@ -59,6 +83,14 @@ export async function countUsers( return res[0]?.count ?? 0; } +export async function countUsersSimple( + tx: PgTransaction, + where?: any +) { + const res = await tx.select({ count: count() }).from(users).where(where); + return res[0]?.count ?? 0; +} + export async function groupByCompany( tx: PgTransaction, ) { -- cgit v1.2.3