feat(mng): 삭제된 데이터 백업 기능 추가
- ArchivedRecord, ArchivedRecordRelation 모델 추가 - ArchivedRecordService 추가 (읽기 전용) - 목록/상세 컨트롤러 및 뷰 구현 - HTMX 기반 테이블 필터링 및 페이지네이션 - 사이드바 메뉴 연결
This commit is contained in:
87
app/Http/Controllers/Api/Admin/ArchivedRecordController.php
Normal file
87
app/Http/Controllers/Api/Admin/ArchivedRecordController.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ArchivedRecordService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ArchivedRecordController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ArchivedRecordService $archivedRecordService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 아카이브 레코드 목록 조회
|
||||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
$records = $this->archivedRecordService->getArchivedRecords(
|
||||
$request->all(),
|
||||
$request->integer('per_page', 15)
|
||||
);
|
||||
|
||||
// HTMX 요청 시 HTML 반환
|
||||
if ($request->header('HX-Request')) {
|
||||
$html = view('archived-records.partials.table', compact('records'))->render();
|
||||
|
||||
return response()->json([
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
// 일반 요청 시 JSON 반환
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $records->items(),
|
||||
'meta' => [
|
||||
'current_page' => $records->currentPage(),
|
||||
'last_page' => $records->lastPage(),
|
||||
'per_page' => $records->perPage(),
|
||||
'total' => $records->total(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 아카이브 레코드 조회
|
||||
*/
|
||||
public function show(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$record = $this->archivedRecordService->getArchivedRecordById($id);
|
||||
|
||||
if (! $record) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '아카이브 레코드를 찾을 수 없습니다.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
// HTMX 요청 시 HTML 반환
|
||||
if ($request->header('HX-Request')) {
|
||||
return response()->json([
|
||||
'html' => view('archived-records.partials.detail', compact('record'))->render(),
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $record,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 아카이브 통계
|
||||
*/
|
||||
public function stats(Request $request): JsonResponse
|
||||
{
|
||||
$stats = $this->archivedRecordService->getStats();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $stats,
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
app/Http/Controllers/ArchivedRecordController.php
Normal file
37
app/Http/Controllers/ArchivedRecordController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\ArchivedRecordService;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ArchivedRecordController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ArchivedRecordService $archivedRecordService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 아카이브 레코드 목록 (Blade 화면만)
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$deletedByUsers = $this->archivedRecordService->getDeletedByUsers();
|
||||
|
||||
return view('archived-records.index', compact('deletedByUsers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 아카이브 레코드 상세 보기 (Blade 화면만)
|
||||
*/
|
||||
public function show(int $id): View
|
||||
{
|
||||
$record = $this->archivedRecordService->getArchivedRecordById($id);
|
||||
|
||||
if (! $record) {
|
||||
abort(404, '아카이브 레코드를 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return view('archived-records.show', compact('record'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user