Files
sam-api/app/Swagger/v1/ItemsApi.php
hskwon a23b727557 feat: Items API CRUD 기능 추가 (BP-MES Phase 1 Day 3-5)
- ItemsController 및 ItemsService CRUD 메서드 구현
- FormRequest 검증 클래스 추가 (ItemStoreRequest, ItemUpdateRequest)
- Swagger 문서 완성 (ItemsApi.php)
- 품목 생성/조회/수정/삭제 엔드포인트 추가
- i18n 메시지 키 추가 (message.item)
- Code 기반 라우팅 적용
- Hybrid 구조 지원 (고정 필드 + attributes JSON)
2025-11-17 11:22:49 +09:00

205 lines
8.1 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Items", description="품목 관리 (Product CRUD)")
*
* @OA\Schema(
* schema="Item",
* type="object",
* required={"id","code","name","product_type","unit"},
*
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="code", type="string", example="P-001"),
* @OA\Property(property="name", type="string", example="스크린 제품 A"),
* @OA\Property(property="product_type", type="string", example="FG", description="FG,PT,SM,RM,CS"),
* @OA\Property(property="unit", type="string", example="EA"),
* @OA\Property(property="category_id", type="integer", nullable=true, example=1),
* @OA\Property(property="description", type="string", nullable=true, example="제품 설명"),
* @OA\Property(property="is_sellable", type="boolean", example=true),
* @OA\Property(property="is_purchasable", type="boolean", example=false),
* @OA\Property(property="is_producible", type="boolean", example=false),
* @OA\Property(property="safety_stock", type="integer", nullable=true, example=10),
* @OA\Property(property="lead_time", type="integer", nullable=true, example=7),
* @OA\Property(property="is_variable_size", type="boolean", example=false),
* @OA\Property(property="product_category", type="string", nullable=true, example="SCREEN"),
* @OA\Property(property="part_type", type="string", nullable=true, example="ASSEMBLY"),
* @OA\Property(
* property="attributes",
* type="object",
* nullable=true,
* description="동적 속성 (JSON)",
* example={"color": "black", "weight": 5.5}
* ),
* @OA\Property(property="created_at", type="string", example="2025-11-14 10:00:00"),
* @OA\Property(property="updated_at", type="string", example="2025-11-14 10:10:00")
* )
*
* @OA\Schema(
* schema="ItemCreateRequest",
* type="object",
* required={"code","name","product_type","unit"},
*
* @OA\Property(property="code", type="string", maxLength=50, example="P-001"),
* @OA\Property(property="name", type="string", maxLength=255, example="스크린 제품 A"),
* @OA\Property(property="product_type", type="string", example="FG", description="FG,PT,SM,RM,CS"),
* @OA\Property(property="unit", type="string", maxLength=20, example="EA"),
* @OA\Property(property="category_id", type="integer", nullable=true, example=1),
* @OA\Property(property="description", type="string", nullable=true, example="제품 설명"),
* @OA\Property(property="is_sellable", type="boolean", nullable=true, example=true),
* @OA\Property(property="is_purchasable", type="boolean", nullable=true, example=false),
* @OA\Property(property="is_producible", type="boolean", nullable=true, example=false),
* @OA\Property(property="safety_stock", type="integer", nullable=true, example=10),
* @OA\Property(property="lead_time", type="integer", nullable=true, example=7),
* @OA\Property(property="is_variable_size", type="boolean", nullable=true, example=false),
* @OA\Property(property="product_category", type="string", nullable=true, example="SCREEN"),
* @OA\Property(property="part_type", type="string", nullable=true, example="ASSEMBLY"),
* @OA\Property(
* property="attributes",
* type="object",
* nullable=true,
* description="동적 속성 (JSON)"
* )
* )
*
* @OA\Schema(
* schema="ItemUpdateRequest",
* type="object",
*
* @OA\Property(property="code", type="string", maxLength=50, example="P-001"),
* @OA\Property(property="name", type="string", maxLength=255, example="스크린 제품 A"),
* @OA\Property(property="product_type", type="string", example="FG", description="FG,PT,SM,RM,CS"),
* @OA\Property(property="unit", type="string", maxLength=20, example="EA"),
* @OA\Property(property="category_id", type="integer", nullable=true, example=1),
* @OA\Property(property="description", type="string", nullable=true, example="제품 설명"),
* @OA\Property(property="is_sellable", type="boolean", nullable=true, example=true),
* @OA\Property(property="is_purchasable", type="boolean", nullable=true, example=false),
* @OA\Property(property="is_producible", type="boolean", nullable=true, example=false),
* @OA\Property(property="safety_stock", type="integer", nullable=true, example=10),
* @OA\Property(property="lead_time", type="integer", nullable=true, example=7),
* @OA\Property(property="is_variable_size", type="boolean", nullable=true, example=false),
* @OA\Property(property="product_category", type="string", nullable=true, example="SCREEN"),
* @OA\Property(property="part_type", type="string", nullable=true, example="ASSEMBLY"),
* @OA\Property(
* property="attributes",
* type="object",
* nullable=true,
* description="동적 속성 (JSON)"
* )
* )
*/
class ItemsApi
{
/**
* @OA\Post(
* path="/api/v1/items",
* tags={"Items"},
* summary="품목 생성",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/ItemCreateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
* type="object",
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="품목이 등록되었습니다."),
* @OA\Property(property="data", ref="#/components/schemas/Item")
* )
* )
* )
*/
public function store() {}
/**
* @OA\Get(
* path="/api/v1/items/code/{code}",
* tags={"Items"},
* summary="품목 코드로 상세 조회",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="code", in="path", required=true, @OA\Schema(type="string"), example="P-001"),
* @OA\Parameter(name="include_bom", in="query", @OA\Schema(type="boolean"), example=false),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
* type="object",
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="품목을 조회했습니다."),
* @OA\Property(property="data", ref="#/components/schemas/Item")
* )
* )
* )
*/
public function showByCode() {}
/**
* @OA\Put(
* path="/api/v1/items/{code}",
* tags={"Items"},
* summary="품목 수정",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="code", in="path", required=true, @OA\Schema(type="string"), example="P-001"),
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/ItemUpdateRequest")
* ),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
* type="object",
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="품목이 수정되었습니다."),
* @OA\Property(property="data", ref="#/components/schemas/Item")
* )
* )
* )
*/
public function update() {}
/**
* @OA\Delete(
* path="/api/v1/items/{code}",
* tags={"Items"},
* summary="품목 삭제",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="code", in="path", required=true, @OA\Schema(type="string"), example="P-001"),
*
* @OA\Response(
* response=200,
* description="성공",
*
* @OA\JsonContent(
* type="object",
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="품목이 삭제되었습니다."),
* @OA\Property(property="data", type="string", example="success")
* )
* )
* )
*/
public function destroy() {}
}