85 lines
2.3 KiB
PHP
85 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\V1;
|
||
|
|
|
||
|
|
use App\Helpers\ApiResponse;
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Http\Requests\V1\ProcessStep\ReorderProcessStepRequest;
|
||
|
|
use App\Http\Requests\V1\ProcessStep\StoreProcessStepRequest;
|
||
|
|
use App\Http\Requests\V1\ProcessStep\UpdateProcessStepRequest;
|
||
|
|
use App\Services\ProcessStepService;
|
||
|
|
use Illuminate\Http\JsonResponse;
|
||
|
|
|
||
|
|
class ProcessStepController extends Controller
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private readonly ProcessStepService $processStepService
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 목록 조회
|
||
|
|
*/
|
||
|
|
public function index(int $processId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->index($processId),
|
||
|
|
'message.fetched'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 상세 조회
|
||
|
|
*/
|
||
|
|
public function show(int $processId, int $stepId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->show($processId, $stepId),
|
||
|
|
'message.fetched'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 생성
|
||
|
|
*/
|
||
|
|
public function store(StoreProcessStepRequest $request, int $processId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->store($processId, $request->validated()),
|
||
|
|
'message.created'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 수정
|
||
|
|
*/
|
||
|
|
public function update(UpdateProcessStepRequest $request, int $processId, int $stepId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->update($processId, $stepId, $request->validated()),
|
||
|
|
'message.updated'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 삭제
|
||
|
|
*/
|
||
|
|
public function destroy(int $processId, int $stepId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->destroy($processId, $stepId),
|
||
|
|
'message.deleted'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 공정 단계 순서 변경
|
||
|
|
*/
|
||
|
|
public function reorder(ReorderProcessStepRequest $request, int $processId): JsonResponse
|
||
|
|
{
|
||
|
|
return ApiResponse::handle(
|
||
|
|
fn () => $this->processStepService->reorder($processId, $request->validated('items')),
|
||
|
|
'message.reordered'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|