summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation')
-rw-r--r--lib/vendor-investigation/approval-actions.ts2
-rw-r--r--lib/vendor-investigation/handlers.ts25
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/vendor-investigation/approval-actions.ts b/lib/vendor-investigation/approval-actions.ts
index 5da30011..e8e24ddc 100644
--- a/lib/vendor-investigation/approval-actions.ts
+++ b/lib/vendor-investigation/approval-actions.ts
@@ -100,6 +100,7 @@ export async function requestPQInvestigationWithApproval(data: {
forecastedAt: data.forecastedAt,
investigationAddress: data.investigationAddress,
investigationNotes: data.investigationNotes,
+ currentUserId: data.currentUser.id, // ✅ 결재 승인 후 핸들러 실행 시 필요
},
// approvalConfig: 결재 상신 정보 (템플릿 포함)
@@ -227,6 +228,7 @@ export async function reRequestPQInvestigationWithApproval(data: {
// actionPayload: 결재 승인 후 핸들러에 전달될 데이터 (최소 데이터만)
{
investigationIds: data.investigationIds,
+ currentUserId: data.currentUser.id, // ✅ 결재 승인 후 핸들러 실행 시 필요
},
// approvalConfig: 결재 상신 정보 (템플릿 포함)
diff --git a/lib/vendor-investigation/handlers.ts b/lib/vendor-investigation/handlers.ts
index 28a218b5..3165df06 100644
--- a/lib/vendor-investigation/handlers.ts
+++ b/lib/vendor-investigation/handlers.ts
@@ -22,19 +22,28 @@ export async function requestPQInvestigationInternal(payload: {
forecastedAt: Date;
investigationAddress: string;
investigationNotes?: string;
+ currentUserId: number; // ✅ 결재 상신한 사용자 ID
}) {
debugLog('[PQInvestigationHandler] 실사 의뢰 핸들러 시작', {
pqCount: payload.pqSubmissionIds.length,
qmManagerId: payload.qmManagerId,
+ currentUserId: payload.currentUserId,
});
+ // ✅ userId 검증: 핸들러에서 userId가 없으면 잘못된 상황 (예외 처리)
+ if (!payload.currentUserId || payload.currentUserId <= 0) {
+ const errorMessage = 'currentUserId가 없습니다. actionPayload에 currentUserId가 포함되지 않았습니다.';
+ debugError('[PQInvestigationHandler]', errorMessage);
+ throw new Error(errorMessage);
+ }
+
try {
// 기존 PQ 서비스 함수 사용 (DB 트랜잭션 포함)
const { requestInvestigationAction } = await import('@/lib/pq/service');
const result = await requestInvestigationAction(
payload.pqSubmissionIds,
- { id: 0, epId: null, email: undefined }, // 핸들러에서는 currentUser 불필요
+ { id: payload.currentUserId, epId: null, email: undefined }, // ✅ 실제 사용자 ID 전달
{
qmManagerId: payload.qmManagerId,
forecastedAt: payload.forecastedAt,
@@ -106,16 +115,28 @@ export async function mapPQInvestigationToTemplateVariables(payload: {
*/
export async function reRequestPQInvestigationInternal(payload: {
investigationIds: number[];
+ currentUserId: number; // ✅ 결재 상신한 사용자 ID
}) {
debugLog('[PQReRequestHandler] 실사 재의뢰 핸들러 시작', {
investigationCount: payload.investigationIds.length,
+ currentUserId: payload.currentUserId,
});
+ // ✅ userId 검증: 핸들러에서 userId가 없으면 잘못된 상황 (예외 처리)
+ if (!payload.currentUserId || payload.currentUserId <= 0) {
+ const errorMessage = 'currentUserId가 없습니다. actionPayload에 currentUserId가 포함되지 않았습니다.';
+ debugError('[PQReRequestHandler]', errorMessage);
+ throw new Error(errorMessage);
+ }
+
try {
// 기존 PQ 서비스 함수 사용
const { reRequestInvestigationAction } = await import('@/lib/pq/service');
- const result = await reRequestInvestigationAction(payload.investigationIds);
+ const result = await reRequestInvestigationAction(
+ payload.investigationIds,
+ { id: payload.currentUserId } // ✅ 실제 사용자 ID 전달
+ );
if (!result.success) {
debugError('[PQReRequestHandler] 실사 재의뢰 실패', result.error);