summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/mapper/common-mapper-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soap/ecc/mapper/common-mapper-utils.ts')
-rw-r--r--lib/soap/ecc/mapper/common-mapper-utils.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/soap/ecc/mapper/common-mapper-utils.ts b/lib/soap/ecc/mapper/common-mapper-utils.ts
index 2199490a..ed655e0e 100644
--- a/lib/soap/ecc/mapper/common-mapper-utils.ts
+++ b/lib/soap/ecc/mapper/common-mapper-utils.ts
@@ -307,6 +307,57 @@ export interface ProjectInfo {
}
/**
+ * 사번(PERNR)으로 사용자 정보 조회 함수
+ * PERNR(사번)으로 users 테이블의 employeeNumber와 매칭하여 사용자 정보 조회
+ */
+export async function findUserInfoByPERNR(PERNR: string | null): Promise<{
+ userId: number;
+ userName: string;
+ userEmail: string | null;
+ userPhone: string | null;
+ employeeNumber: string | null;
+} | null> {
+ try {
+ debugLog('사번으로 사용자 조회 시작', { PERNR });
+
+ if (!PERNR) {
+ debugError('PERNR이 null 또는 undefined', { PERNR });
+ return null;
+ }
+
+ const userResult = await db
+ .select({
+ id: users.id,
+ name: users.name,
+ email: users.email,
+ phone: users.phone,
+ employeeNumber: users.employeeNumber
+ })
+ .from(users)
+ .where(eq(users.employeeNumber, PERNR))
+ .limit(1);
+
+ if (userResult.length === 0) {
+ debugError('PERNR에 해당하는 사용자를 찾을 수 없음', { PERNR });
+ return null;
+ }
+
+ const userInfo = {
+ userId: userResult[0].id,
+ userName: userResult[0].name,
+ userEmail: userResult[0].email,
+ userPhone: userResult[0].phone,
+ employeeNumber: userResult[0].employeeNumber
+ };
+ debugSuccess('사번으로 사용자 정보 찾음', { PERNR, userInfo });
+ return userInfo;
+ } catch (error) {
+ debugError('사번으로 사용자 조회 중 오류 발생', { PERNR, error });
+ return null;
+ }
+}
+
+/**
* 협력업체 코드(LIFNR)로 vendorId 찾기
* LIFNR = 벤더코드 (ex. A0001234)
* vendors 테이블의 vendorCode 필드와 비교하여 vendorId를 찾음