feat: [hr] 사원관리 퇴직자 영구삭제 기능 추가
- 슈퍼관리자만 퇴직 상태 사원을 영구삭제 가능
- 관련 첨부파일도 함께 삭제
- DELETE /admin/hr/employees/{id}/force 엔드포인트 추가
This commit is contained in:
@@ -263,6 +263,43 @@ public function destroy(Request $request, int $id): JsonResponse|Response
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 영구삭제 (퇴직자만, 슈퍼관리자 전용)
|
||||
*/
|
||||
public function forceDestroy(Request $request, int $id): JsonResponse|Response
|
||||
{
|
||||
if (! auth()->user()?->is_super_admin) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '슈퍼관리자만 영구삭제할 수 있습니다.',
|
||||
], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $this->employeeService->forceDeleteEmployee($id);
|
||||
|
||||
if (! $result['success']) {
|
||||
return response()->json($result, 422);
|
||||
}
|
||||
|
||||
if ($request->header('HX-Request')) {
|
||||
$employees = $this->employeeService->getEmployees($request->all(), $request->integer('per_page', 20));
|
||||
|
||||
return response(view('hr.employees.partials.table', compact('employees')));
|
||||
}
|
||||
|
||||
return response()->json($result);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '영구삭제 중 오류가 발생했습니다.',
|
||||
'error' => config('app.debug') ? $e->getMessage() : null,
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 사원 첨부파일 업로드 (로컬 + GCS 듀얼 저장)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user