summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation/handlers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation/handlers.ts')
-rw-r--r--lib/vendor-investigation/handlers.ts33
1 files changed, 13 insertions, 20 deletions
diff --git a/lib/vendor-investigation/handlers.ts b/lib/vendor-investigation/handlers.ts
index 24cad870..28a218b5 100644
--- a/lib/vendor-investigation/handlers.ts
+++ b/lib/vendor-investigation/handlers.ts
@@ -1,44 +1,40 @@
/**
* PQ 실사 관련 결재 액션 핸들러
*
- * 실제 비즈니스 로직만 포함 (결재 로직은 approval-workflow에서 처리)
+ * ✅ 베스트 프랙티스:
+ * - 'use server' 지시어 없음 (순수 비즈니스 로직만)
+ * - 결재 승인 후 실행될 최소한의 데이터만 처리
+ * - DB 조작 및 실제 비즈니스 로직만 포함
*/
-'use server';
-
-import { requestInvestigationAction } from '@/lib/pq/service';
import { debugLog, debugError, debugSuccess } from '@/lib/debug-utils';
/**
* PQ 실사 의뢰 핸들러 (결재 승인 후 실행됨)
*
- * 이 함수는 직접 호출하지 않고, 결재 워크플로우에서 자동으로 호출됨
+ * ✅ Internal 함수: 결재 워크플로우에서 자동 호출됨 (직접 호출 금지)
*
- * @param payload - withApproval()에서 전달한 actionPayload
+ * @param payload - withApproval()에서 전달한 actionPayload (최소 데이터만)
*/
export async function requestPQInvestigationInternal(payload: {
pqSubmissionIds: number[];
qmManagerId: number;
- qmManagerName?: string;
forecastedAt: Date;
investigationAddress: string;
investigationNotes?: string;
- vendorNames?: string; // 복수 업체 이름 (표시용)
- currentUser: { id: number; epId: string | null; email?: string };
}) {
debugLog('[PQInvestigationHandler] 실사 의뢰 핸들러 시작', {
pqCount: payload.pqSubmissionIds.length,
qmManagerId: payload.qmManagerId,
- currentUser: payload.currentUser,
- vendorNames: payload.vendorNames,
});
try {
- // 실제 실사 의뢰 처리
- debugLog('[PQInvestigationHandler] requestInvestigationAction 호출');
+ // 기존 PQ 서비스 함수 사용 (DB 트랜잭션 포함)
+ const { requestInvestigationAction } = await import('@/lib/pq/service');
+
const result = await requestInvestigationAction(
payload.pqSubmissionIds,
- payload.currentUser,
+ { id: 0, epId: null, email: undefined }, // 핸들러에서는 currentUser 불필요
{
qmManagerId: payload.qmManagerId,
forecastedAt: payload.forecastedAt,
@@ -104,23 +100,20 @@ export async function mapPQInvestigationToTemplateVariables(payload: {
/**
* PQ 실사 재의뢰 핸들러 (결재 승인 후 실행됨)
*
- * 이 함수는 직접 호출하지 않고, 결재 워크플로우에서 자동으로 호출됨
+ * ✅ Internal 함수: 결재 워크플로우에서 자동 호출됨 (직접 호출 금지)
*
- * @param payload - withApproval()에서 전달한 actionPayload
+ * @param payload - withApproval()에서 전달한 actionPayload (최소 데이터만)
*/
export async function reRequestPQInvestigationInternal(payload: {
investigationIds: number[];
- vendorNames?: string; // 복수 업체 이름 (표시용)
}) {
debugLog('[PQReRequestHandler] 실사 재의뢰 핸들러 시작', {
investigationCount: payload.investigationIds.length,
- vendorNames: payload.vendorNames,
});
try {
- // 실제 실사 재의뢰 처리
+ // 기존 PQ 서비스 함수 사용
const { reRequestInvestigationAction } = await import('@/lib/pq/service');
- debugLog('[PQReRequestHandler] reRequestInvestigationAction 호출');
const result = await reRequestInvestigationAction(payload.investigationIds);