- 마이그레이션 4개 (approval_forms, approval_lines, approvals, approval_steps) - 모델 4개 (ApprovalForm, ApprovalLine, Approval, ApprovalStep) - ApprovalService 비즈니스 로직 (양식/결재선 CRUD, 기안함/결재함/참조함, 결재 액션) - 컨트롤러 3개 (ApprovalFormController, ApprovalLineController, ApprovalController) - FormRequest 13개 (양식/결재선/문서 검증) - Swagger 문서 3개 (26개 엔드포인트) - i18n 메시지/에러 키 추가 - 라우트 26개 등록
83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Helpers\ApiResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Approval\FormIndexRequest;
|
|
use App\Http\Requests\Approval\FormStoreRequest;
|
|
use App\Http\Requests\Approval\FormUpdateRequest;
|
|
use App\Services\ApprovalService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class ApprovalFormController extends Controller
|
|
{
|
|
public function __construct(private ApprovalService $service) {}
|
|
|
|
/**
|
|
* 결재 양식 목록
|
|
* GET /v1/approval-forms
|
|
*/
|
|
public function index(FormIndexRequest $request): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($request) {
|
|
return $this->service->formIndex($request->validated());
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 활성 결재 양식 목록 (셀렉트박스용)
|
|
* GET /v1/approval-forms/active
|
|
*/
|
|
public function active(): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () {
|
|
return $this->service->formActive();
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 결재 양식 상세
|
|
* GET /v1/approval-forms/{id}
|
|
*/
|
|
public function show(int $id): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($id) {
|
|
return $this->service->formShow($id);
|
|
}, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 결재 양식 생성
|
|
* POST /v1/approval-forms
|
|
*/
|
|
public function store(FormStoreRequest $request): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($request) {
|
|
return $this->service->formStore($request->validated());
|
|
}, __('message.approval.form_created'));
|
|
}
|
|
|
|
/**
|
|
* 결재 양식 수정
|
|
* PATCH /v1/approval-forms/{id}
|
|
*/
|
|
public function update(int $id, FormUpdateRequest $request): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($id, $request) {
|
|
return $this->service->formUpdate($id, $request->validated());
|
|
}, __('message.updated'));
|
|
}
|
|
|
|
/**
|
|
* 결재 양식 삭제
|
|
* DELETE /v1/approval-forms/{id}
|
|
*/
|
|
public function destroy(int $id): JsonResponse
|
|
{
|
|
return ApiResponse::handle(function () use ($id) {
|
|
return $this->service->formDestroy($id);
|
|
}, __('message.deleted'));
|
|
}
|
|
}
|