Files
sam-api/app/Services/ESign/EsignPdfService.php
김보곤 6958be1fd8 feat:E-Sign 전자계약 서명 솔루션 백엔드 구현
- 마이그레이션 4개 (esign_contracts, esign_signers, esign_sign_fields, esign_audit_logs)
- 모델 4개 (EsignContract, EsignSigner, EsignSignField, EsignAuditLog)
- 서비스 4개 (EsignContractService, EsignSignService, EsignPdfService, EsignAuditService)
- 컨트롤러 2개 (EsignContractController, EsignSignController)
- FormRequest 4개 (ContractStore, FieldConfigure, SignSubmit, SignReject)
- Mail 1개 (EsignRequestMail + 이메일 템플릿)
- API 라우트 (인증 계약 관리 + 토큰 기반 서명 프로세스)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 07:02:39 +09:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Services\ESign;
use App\Services\Service;
use Illuminate\Support\Facades\Storage;
class EsignPdfService extends Service
{
public function generateHash(string $filePath): string
{
$fullPath = Storage::disk('local')->path($filePath);
return hash_file('sha256', $fullPath);
}
public function verifyIntegrity(string $filePath, string $expectedHash): bool
{
$actualHash = $this->generateHash($filePath);
return hash_equals($expectedHash, $actualHash);
}
public function composeSigned(
string $originalPath,
array $signerImages,
array $signFields
): string {
// FPDI/FPDF 기반 PDF 합성 - 추후 구현
// 현재는 원본 파일을 signed 경로로 복사
$signedPath = str_replace('originals/', 'signed/', $originalPath);
$signedDir = dirname(Storage::disk('local')->path($signedPath));
if (! is_dir($signedDir)) {
mkdir($signedDir, 0755, true);
}
Storage::disk('local')->copy($originalPath, $signedPath);
return $signedPath;
}
public function addAuditPage(string $pdfPath, array $auditData): string
{
// 감사 증적 페이지 추가 - 추후 FPDI/FPDF로 구현
return $pdfPath;
}
}