Files
sam-api/app/Swagger/v1/ApprovalFormApi.php
hskwon b43796a558 feat: [approval] 전자결재 모듈 API 구현
- 마이그레이션 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개 등록
2025-12-17 23:23:20 +09:00

278 lines
13 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Approval Forms", description="결재 양식 관리")
*
* @OA\Schema(
* schema="ApprovalForm",
* type="object",
* description="결재 양식 정보",
*
* @OA\Property(property="id", type="integer", example=1, description="양식 ID"),
* @OA\Property(property="tenant_id", type="integer", example=1, description="테넌트 ID"),
* @OA\Property(property="name", type="string", example="품의서", description="양식명"),
* @OA\Property(property="code", type="string", example="REQUEST_01", description="양식 코드"),
* @OA\Property(property="category", type="string", enum={"request","expense","expense_estimate"}, example="request", nullable=true, description="카테고리"),
* @OA\Property(property="template", type="object", description="템플릿 JSON",
* @OA\Property(property="fields", type="array", @OA\Items(type="object",
* @OA\Property(property="name", type="string", example="title"),
* @OA\Property(property="type", type="string", example="text"),
* @OA\Property(property="label", type="string", example="제목"),
* @OA\Property(property="required", type="boolean", example=true)
* ))
* ),
* @OA\Property(property="is_active", type="boolean", example=true, description="활성 여부"),
* @OA\Property(property="creator", type="object", nullable=true, description="생성자 정보",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="관리자")
* ),
* @OA\Property(property="created_at", type="string", format="date-time", example="2024-01-01T09:00:00Z"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2024-01-01T09:00:00Z")
* )
*
* @OA\Schema(
* schema="ApprovalFormCreateRequest",
* type="object",
* required={"name", "code", "template"},
* description="결재 양식 생성 요청",
*
* @OA\Property(property="name", type="string", example="품의서", description="양식명"),
* @OA\Property(property="code", type="string", example="REQUEST_01", description="양식 코드 (영문, 숫자, _, -)"),
* @OA\Property(property="category", type="string", enum={"request","expense","expense_estimate"}, example="request", description="카테고리"),
* @OA\Property(property="template", type="object", description="템플릿 JSON",
* @OA\Property(property="fields", type="array", @OA\Items(type="object"))
* ),
* @OA\Property(property="is_active", type="boolean", example=true, description="활성 여부")
* )
*
* @OA\Schema(
* schema="ApprovalFormUpdateRequest",
* type="object",
* description="결재 양식 수정 요청",
*
* @OA\Property(property="name", type="string", example="품의서", description="양식명"),
* @OA\Property(property="code", type="string", example="REQUEST_01", description="양식 코드"),
* @OA\Property(property="category", type="string", enum={"request","expense","expense_estimate"}, description="카테고리"),
* @OA\Property(property="template", type="object", description="템플릿 JSON"),
* @OA\Property(property="is_active", type="boolean", description="활성 여부")
* )
*/
class ApprovalFormApi
{
/**
* @OA\Get(
* path="/api/v1/approval-forms",
* tags={"Approval Forms"},
* summary="결재 양식 목록 조회",
* description="필터/검색/페이지네이션으로 결재 양식 목록을 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="category", in="query", description="카테고리 필터", @OA\Schema(type="string", enum={"request","expense","expense_estimate"})),
* @OA\Parameter(name="is_active", in="query", description="활성 상태 필터", @OA\Schema(type="boolean")),
* @OA\Parameter(name="search", in="query", description="검색어 (이름, 코드)", @OA\Schema(type="string")),
* @OA\Parameter(name="sort_by", in="query", description="정렬 기준", @OA\Schema(type="string", enum={"created_at","name","code","category"}, default="created_at")),
* @OA\Parameter(name="sort_dir", in="query", description="정렬 방향", @OA\Schema(type="string", enum={"asc","desc"}, default="desc")),
* @OA\Parameter(ref="#/components/parameters/Page"),
* @OA\Parameter(ref="#/components/parameters/Size"),
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(
* property="data",
* type="object",
* @OA\Property(property="current_page", type="integer", example=1),
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/ApprovalForm")),
* @OA\Property(property="per_page", type="integer", example=20),
* @OA\Property(property="total", type="integer", example=10)
* )
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function index() {}
/**
* @OA\Get(
* path="/api/v1/approval-forms/active",
* tags={"Approval Forms"},
* summary="활성 결재 양식 목록 (셀렉트박스용)",
* description="활성화된 결재 양식만 간략하게 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(
* property="data",
* type="array",
*
* @OA\Items(type="object",
*
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="품의서"),
* @OA\Property(property="code", type="string", example="REQUEST_01"),
* @OA\Property(property="category", type="string", example="request")
* )
* )
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function active() {}
/**
* @OA\Get(
* path="/api/v1/approval-forms/{id}",
* tags={"Approval Forms"},
* summary="결재 양식 상세 조회",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="양식 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ApprovalForm"))
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="양식을 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function show() {}
/**
* @OA\Post(
* path="/api/v1/approval-forms",
* tags={"Approval Forms"},
* summary="결재 양식 생성",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/ApprovalFormCreateRequest")
* ),
*
* @OA\Response(
* response=201,
* description="생성 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ApprovalForm"))
* }
* )
* ),
*
* @OA\Response(response=400, description="잘못된 요청 (코드 중복 등)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function store() {}
/**
* @OA\Patch(
* path="/api/v1/approval-forms/{id}",
* tags={"Approval Forms"},
* summary="결재 양식 수정",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="양식 ID", @OA\Schema(type="integer")),
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/ApprovalFormUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ApprovalForm"))
* }
* )
* ),
*
* @OA\Response(response=400, description="잘못된 요청", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="양식을 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function update() {}
/**
* @OA\Delete(
* path="/api/v1/approval-forms/{id}",
* tags={"Approval Forms"},
* summary="결재 양식 삭제",
* description="사용 중인 양식은 삭제할 수 없습니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Parameter(name="id", in="path", required=true, description="양식 ID", @OA\Schema(type="integer")),
*
* @OA\Response(
* response=200,
* description="삭제 성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="삭제 완료"),
* @OA\Property(property="data", type="boolean", example=true)
* )
* ),
*
* @OA\Response(response=400, description="삭제 불가 (사용 중)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="양식을 찾을 수 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function destroy() {}
}