feat:트리거 관리(4.4) + 파티션 관리(4.6) UI 구현
- TriggerManagementService: 테이블별 트리거 상태 조회/재생성/삭제 - PartitionManagementService: 파티션 현황 조회/추가/삭제 (보관기간 검증) - triggers.blade.php: 트리거 상태 대시보드 + 개별/전체 재생성·삭제 - partitions.blade.php: 파티션 통계 + 추가/삭제 (초과분만) - sub-nav: 감사 로그 목록/트리거 관리/파티션 관리 탭 내비게이션 - 라우트 6개 추가, 컨트롤러 6개 메서드 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,19 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Audit\TriggerAuditLog;
|
||||
use App\Services\PartitionManagementService;
|
||||
use App\Services\TriggerManagementService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class TriggerAuditController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private TriggerManagementService $triggerService,
|
||||
private PartitionManagementService $partitionService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 트리거 감사 로그 목록 + 통계 대시보드
|
||||
*/
|
||||
@@ -225,4 +232,100 @@ private function buildReinsertSQL(TriggerAuditLog $log, \PDO $pdo): string
|
||||
|
||||
return "INSERT INTO `{$log->table_name}` ({$cols}) VALUES ({$vals})";
|
||||
}
|
||||
|
||||
// ── 4.4 트리거 관리 ──────────────────────────────
|
||||
|
||||
/**
|
||||
* 트리거 관리 페이지
|
||||
*/
|
||||
public function triggers(): View
|
||||
{
|
||||
$data = $this->triggerService->getTableTriggerStatus();
|
||||
|
||||
return view('trigger-audit.triggers', compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 트리거 재생성 (단일 또는 전체)
|
||||
*/
|
||||
public function regenerateTrigger(Request $request)
|
||||
{
|
||||
$tableName = $request->input('table_name');
|
||||
|
||||
try {
|
||||
$result = $this->triggerService->regenerate($tableName);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->route('trigger-audit.triggers')
|
||||
->with('error', '트리거 재생성 실패: '.$e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('trigger-audit.triggers')
|
||||
->with($result['success'] ? 'success' : 'error', $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 트리거 삭제 (단일 또는 전체)
|
||||
*/
|
||||
public function dropTrigger(Request $request)
|
||||
{
|
||||
$tableName = $request->input('table_name');
|
||||
|
||||
try {
|
||||
$result = $this->triggerService->drop($tableName);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->route('trigger-audit.triggers')
|
||||
->with('error', '트리거 삭제 실패: '.$e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('trigger-audit.triggers')
|
||||
->with($result['success'] ? 'success' : 'error', $result['message']);
|
||||
}
|
||||
|
||||
// ── 4.6 파티션 관리 ──────────────────────────────
|
||||
|
||||
/**
|
||||
* 파티션 관리 페이지
|
||||
*/
|
||||
public function partitions(): View
|
||||
{
|
||||
$data = $this->partitionService->getPartitions();
|
||||
|
||||
return view('trigger-audit.partitions', compact('data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 미래 파티션 추가
|
||||
*/
|
||||
public function addPartitions(Request $request)
|
||||
{
|
||||
$request->validate(['months' => 'required|integer|min:1|max:12']);
|
||||
|
||||
try {
|
||||
$result = $this->partitionService->addFuturePartitions((int) $request->months);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->route('trigger-audit.partitions')
|
||||
->with('error', '파티션 추가 실패: '.$e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('trigger-audit.partitions')
|
||||
->with($result['success'] ? 'success' : 'error', $result['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 파티션 삭제
|
||||
*/
|
||||
public function dropPartition(Request $request)
|
||||
{
|
||||
$request->validate(['partition_name' => 'required|string']);
|
||||
|
||||
try {
|
||||
$result = $this->partitionService->dropPartition($request->partition_name);
|
||||
} catch (\Throwable $e) {
|
||||
return redirect()->route('trigger-audit.partitions')
|
||||
->with('error', '파티션 삭제 실패: '.$e->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->route('trigger-audit.partitions')
|
||||
->with($result['success'] ? 'success' : 'error', $result['message']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user