2025-12-26 18:56:24 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\V1;
|
|
|
|
|
|
|
|
|
|
use App\Helpers\ApiResponse;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Requests\V1\Process\StoreProcessRequest;
|
|
|
|
|
use App\Http\Requests\V1\Process\UpdateProcessRequest;
|
|
|
|
|
use App\Services\ProcessService;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class ProcessController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly ProcessService $processService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 목록 조회
|
|
|
|
|
*/
|
|
|
|
|
public function index(Request $request): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->index(
|
|
|
|
|
$request->only(['page', 'size', 'q', 'status', 'process_type'])
|
|
|
|
|
),
|
|
|
|
|
'message.fetched'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 상세 조회
|
|
|
|
|
*/
|
|
|
|
|
public function show(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->show($id),
|
|
|
|
|
'message.fetched'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 생성
|
|
|
|
|
*/
|
|
|
|
|
public function store(StoreProcessRequest $request): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->store($request->validated()),
|
|
|
|
|
'message.created'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 수정
|
|
|
|
|
*/
|
|
|
|
|
public function update(UpdateProcessRequest $request, int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->update($id, $request->validated()),
|
|
|
|
|
'message.updated'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 삭제
|
|
|
|
|
*/
|
|
|
|
|
public function destroy(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->destroy($id),
|
|
|
|
|
'message.deleted'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 일괄 삭제
|
|
|
|
|
*/
|
|
|
|
|
public function destroyMany(Request $request): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => ['deleted_count' => $this->processService->destroyMany($request->input('ids', []))],
|
|
|
|
|
'message.deleted'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 상태 토글
|
|
|
|
|
*/
|
|
|
|
|
public function toggleActive(int $id): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->toggleActive($id),
|
|
|
|
|
'message.updated'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 옵션 목록 (드롭다운용)
|
|
|
|
|
*/
|
|
|
|
|
public function options(): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->options(),
|
|
|
|
|
'message.fetched'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 공정 통계
|
|
|
|
|
*/
|
|
|
|
|
public function stats(): JsonResponse
|
|
|
|
|
{
|
2025-12-30 17:25:29 +09:00
|
|
|
return ApiResponse::handle(
|
|
|
|
|
fn () => $this->processService->getStats(),
|
|
|
|
|
'message.fetched'
|
|
|
|
|
);
|
2025-12-26 18:56:24 +09:00
|
|
|
}
|
|
|
|
|
}
|