feat: [roadmap] 중장기 계획 메뉴 및 전용 페이지 개발
- 모델: AdminRoadmapPlan, AdminRoadmapMilestone - 서비스: RoadmapPlanService, RoadmapMilestoneService - FormRequest: Store/Update Plan/Milestone 4개 - 컨트롤러: Blade(RoadmapController), API(Plan/Milestone) 3개 - 라우트: web.php, api.php에 roadmap 라우트 추가 - Blade 뷰: 대시보드, 목록, 생성, 수정, 상세, 파셜 테이블 6개 - HTMX 기반 필터링/페이지네이션, 마일스톤 인라인 추가/토글
This commit is contained in:
130
app/Http/Controllers/Api/Admin/Roadmap/RoadmapPlanController.php
Normal file
130
app/Http/Controllers/Api/Admin/Roadmap/RoadmapPlanController.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Admin\Roadmap;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Roadmap\StorePlanRequest;
|
||||
use App\Http\Requests\Roadmap\UpdatePlanRequest;
|
||||
use App\Services\Roadmap\RoadmapPlanService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RoadmapPlanController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RoadmapPlanService $planService
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View|JsonResponse
|
||||
{
|
||||
$filters = $request->only([
|
||||
'search', 'status', 'category', 'priority', 'phase',
|
||||
'trashed', 'sort_by', 'sort_direction',
|
||||
]);
|
||||
$plans = $this->planService->getPlans($filters, 15);
|
||||
|
||||
if ($request->header('HX-Request')) {
|
||||
return view('roadmap.plans.partials.table', compact('plans'));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $plans,
|
||||
]);
|
||||
}
|
||||
|
||||
public function stats(): JsonResponse
|
||||
{
|
||||
$stats = $this->planService->getStats();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $stats,
|
||||
]);
|
||||
}
|
||||
|
||||
public function timeline(Request $request): JsonResponse
|
||||
{
|
||||
$phase = $request->input('phase');
|
||||
$timeline = $this->planService->getTimelineData($phase);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $timeline,
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(int $id): JsonResponse
|
||||
{
|
||||
$plan = $this->planService->getPlanById($id, true);
|
||||
|
||||
if (! $plan) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => '계획을 찾을 수 없습니다.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $plan,
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(StorePlanRequest $request): JsonResponse
|
||||
{
|
||||
$plan = $this->planService->createPlan($request->validated());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계획이 생성되었습니다.',
|
||||
'data' => $plan,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(UpdatePlanRequest $request, int $id): JsonResponse
|
||||
{
|
||||
$this->planService->updatePlan($id, $request->validated());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계획이 수정되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy(int $id): JsonResponse
|
||||
{
|
||||
$this->planService->deletePlan($id);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계획이 삭제되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function restore(int $id): JsonResponse
|
||||
{
|
||||
$this->planService->restorePlan($id);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계획이 복원되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function changeStatus(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'status' => 'required|in:planned,in_progress,completed,delayed,cancelled',
|
||||
]);
|
||||
|
||||
$plan = $this->planService->changeStatus($id, $validated['status']);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '상태가 변경되었습니다.',
|
||||
'data' => $plan,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user