diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-26 12:10:51 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-26 12:10:51 +0000 |
| commit | f61e9e9c6ea5b415d64ecb9f703a0633a5029da4 (patch) | |
| tree | 1088886f7b59071a401664b993d30ec173e9caef /lib/shi-api | |
| parent | 1110427907bbe9c11a378da4c1a233b83b5ca3b1 (diff) | |
(김준회) shi-api 기준 유저 업데이트시 부서별 권한 업데이트 로직 함께 수행하도록 변경
Diffstat (limited to 'lib/shi-api')
| -rw-r--r-- | lib/shi-api/shi-api-utils.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/shi-api/shi-api-utils.ts b/lib/shi-api/shi-api-utils.ts index c0b62b0d..bb80c454 100644 --- a/lib/shi-api/shi-api-utils.ts +++ b/lib/shi-api/shi-api-utils.ts @@ -4,6 +4,7 @@ import { nonsapUser, users } from '@/db/schema'; import db from '@/db/db'; import { debugError, debugLog, debugWarn, debugSuccess } from '@/lib/debug-utils'; import { bulkUpsert } from '@/lib/soap/batch-utils'; +import { autoAssignPendingUsersDomains } from '@/lib/users/department-domain/service'; const shiApiBaseUrl = process.env.SHI_API_BASE_URL; const shiNonsapUserSegment = process.env.SHI_NONSAP_USER_SEGMENT; @@ -110,10 +111,11 @@ export const getAllNonsapUser = async () => { knoxId: u.MYSNG_ID || undefined, name: u.USR_NM || undefined, email: u.EMAIL_ADR || undefined, - epId: u.MYSNG_ID || undefined, + epId: u.MYSNG_USR_ID || undefined, deptCode: u.DEPTCD || undefined, deptName: u.DEPTNM || undefined, phone: u.HP_NO || undefined, + domain: 'pending', // SHI-API를 통해 동기화되는 사용자는 pending 도메인으로 설정 isAbsent, isDeletedOnNonSap: isDeleted, isActive, @@ -155,6 +157,16 @@ export const getAllNonsapUser = async () => { // 휴직 사용자도 API에서 수신하므로, 기존 사용자와의 비교를 통한 휴직 처리 로직은 더 이상 필요하지 않음 + // ** 4. 사용자 동기화 완료 후 부서별 도메인 자동 할당 처리 ** + debugLog('[DOMAIN-AUTO-ASSIGN] SHI-API 동기화 완료 후 부서별 도메인 자동 할당 시작'); + try { + const domainAssignResult = await autoAssignPendingUsersDomains(); + debugSuccess(`[DOMAIN-AUTO-ASSIGN] 부서별 도메인 자동 할당 완료: ${domainAssignResult.message}`); + } catch (domainError) { + debugError('[DOMAIN-AUTO-ASSIGN] 부서별 도메인 자동 할당 실패', domainError); + // 도메인 할당 실패해도 메인 동기화 결과는 반환 + } + return { fetched: Array.isArray(data) ? data.length : 0, staged: Array.isArray(data) ? data.length : 0, |
