Files
sam-api/app/Swagger/v1/ItemsApi.php
hskwon f09fa3791c feat: [items] 아이템 API 기능 개선
- ItemsController, ItemsBomController, ItemsFileController 수정
- ItemBatchDeleteRequest 추가
- ItemsService 개선
- ItemsApi Swagger 문서 업데이트
2025-11-30 21:05:44 +09:00

285 lines
11 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)"
* )
* )
*
* @OA\Schema(
* schema="ItemBatchDeleteRequest",
* type="object",
* required={"ids"},
*
* @OA\Property(
* property="ids",
* type="array",
* description="삭제할 품목 ID 목록",
*
* @OA\Items(type="integer"),
* example={1, 2, 3}
* )
* )
*/
class ItemsApi
{
/**
* @OA\Get(
* path="/api/v1/items",
* tags={"Items"},
* summary="품목 목록 조회 (통합)",
* description="Product + Material 통합 조회, 페이징 지원",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(ref="#/components/parameters/Page"),
* @OA\Parameter(ref="#/components/parameters/Size"),
* @OA\Parameter(name="search", in="query", @OA\Schema(type="string"), description="검색어 (code, name)", example="P-001"),
* @OA\Parameter(name="product_type", in="query", @OA\Schema(type="string"), description="품목 타입 필터 (FG,PT,SM,RM,CS)", example="FG"),
* @OA\Parameter(name="category_id", in="query", @OA\Schema(type="integer"), description="카테고리 ID 필터", example=1),
* @OA\Parameter(name="is_active", in="query", @OA\Schema(type="boolean"), description="활성 상태 필터", example=true),
*
* @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="array", @OA\Items(ref="#/components/schemas/Item")),
* @OA\Property(property="meta", ref="#/components/schemas/PaginationMeta")
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function index() {}
/**
* @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/{id}",
* tags={"Items"},
* summary="품목 수정",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer"), example=1, description="품목 ID"),
*
* @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/{id}",
* tags={"Items"},
* summary="품목 삭제",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer"), example=1, description="품목 ID"),
*
* @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() {}
/**
* @OA\Delete(
* path="/api/v1/items/batch",
* tags={"Items"},
* summary="품목 일괄 삭제",
* description="여러 품목을 한 번에 삭제합니다.",
* security={{"ApiKeyAuth": {}, "BearerAuth": {}}},
*
* @OA\RequestBody(
* required=true,
*
* @OA\JsonContent(ref="#/components/schemas/ItemBatchDeleteRequest")
* ),
*
* @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 batchDestroy() {}
}