refactor: [approval] 재직증명서 DOCX 생성을 제거하고 content JSON 저장 + PDF 다운로드 방식으로 변경
- 상신 시 DOCX 생성 API 호출 제거, content JSON만 저장 - show 페이지에 PDF 다운로드 버튼 추가 - TCPDF 기반 PDF 생성 (기존 Pretendard 한글 폰트 활용) - EmploymentCertService에서 generateDocx/createFileRecord 제거
This commit is contained in:
@@ -279,48 +279,17 @@ public function certInfo(int $userId): JsonResponse
|
||||
}
|
||||
|
||||
/**
|
||||
* 재직증명서 DOCX 생성
|
||||
* 재직증명서 PDF 다운로드 (content JSON 기반 HTML→PDF)
|
||||
*/
|
||||
public function generateCertDocx(Request $request): JsonResponse
|
||||
public function certPdf(int $id)
|
||||
{
|
||||
$request->validate([
|
||||
'user_id' => 'required|integer',
|
||||
'purpose' => 'required|string|max:200',
|
||||
'address' => 'nullable|string|max:500',
|
||||
]);
|
||||
$approval = \App\Models\Approvals\Approval::where('tenant_id', session('selected_tenant_id'))
|
||||
->findOrFail($id);
|
||||
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id');
|
||||
$service = app(EmploymentCertService::class);
|
||||
$certInfo = $service->getCertInfo($request->input('user_id'), $tenantId);
|
||||
$content = $approval->content ?? [];
|
||||
$service = app(EmploymentCertService::class);
|
||||
|
||||
// 주소가 수정된 경우 덮어쓰기
|
||||
if ($request->filled('address')) {
|
||||
$certInfo['address'] = $request->input('address');
|
||||
}
|
||||
$certInfo['purpose'] = $request->input('purpose');
|
||||
|
||||
$storagePath = $service->generateDocx($certInfo, $tenantId);
|
||||
$displayName = '재직증명서_'.($certInfo['name'] ?? '').'_'.date('Ymd').'.docx';
|
||||
$fileRecord = $service->createFileRecord($storagePath, $displayName, $tenantId);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'file_id' => $fileRecord->id,
|
||||
'file_name' => $displayName,
|
||||
],
|
||||
'message' => '재직증명서가 생성되었습니다.',
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '재직증명서 생성에 실패했습니다.',
|
||||
'error' => config('app.debug') ? $e->getMessage() : null,
|
||||
], 500);
|
||||
}
|
||||
return $service->generatePdfResponse($content);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user