feat: [approval] 재직증명서 기안 기능 추가
- EmploymentCertService: 사원 정보 조회, DOCX 생성, 파일 레코드 생성
- API 엔드포인트: cert-info/{userId}, generate-cert-docx
- _certificate-form: 인적사항/재직사항/발급정보 입력 폼
- _certificate-show: 재직증명서 읽기전용 표시 파셜
- create/edit/show에 employment_cert 양식 분기 처리
- phpoffice/phpword 패키지 추가
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Boards\File;
|
||||
use App\Services\ApprovalService;
|
||||
use App\Services\EmploymentCertService;
|
||||
use App\Services\GoogleCloudStorageService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -254,6 +255,74 @@ public function bulkDestroy(Request $request): JsonResponse
|
||||
]);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 재직증명서
|
||||
// =========================================================================
|
||||
|
||||
/**
|
||||
* 사원 재직증명서 정보 조회
|
||||
*/
|
||||
public function certInfo(int $userId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id');
|
||||
$service = app(EmploymentCertService::class);
|
||||
$data = $service->getCertInfo($userId, $tenantId);
|
||||
|
||||
return response()->json(['success' => true, 'data' => $data]);
|
||||
} catch (\Throwable $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '사원 정보를 불러올 수 없습니다.',
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 재직증명서 DOCX 생성
|
||||
*/
|
||||
public function generateCertDocx(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'user_id' => 'required|integer',
|
||||
'purpose' => 'required|string|max:200',
|
||||
'address' => 'nullable|string|max:500',
|
||||
]);
|
||||
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id');
|
||||
$service = app(EmploymentCertService::class);
|
||||
$certInfo = $service->getCertInfo($request->input('user_id'), $tenantId);
|
||||
|
||||
// 주소가 수정된 경우 덮어쓰기
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 워크플로우
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user