- MaterialStoreRequest.php 생성 (검증 로직 분리) - MaterialUpdateRequest.php 생성 (검증 로직 분리) - MaterialApi.php 경로 수정 (/api/v1/products/materials) - MaterialController.php Swagger 주석 제거, FormRequest 적용 - lang/ko/message.php material 메시지 키 추가 - SAM API Development Rules 준수 완료
317 lines
12 KiB
PHP
317 lines
12 KiB
PHP
<?php
|
|
|
|
namespace App\Swagger\v1;
|
|
|
|
/**
|
|
* @OA\Tag(
|
|
* name="Material",
|
|
* description="자재 관리(목록/등록/조회/수정/삭제)"
|
|
* )
|
|
*/
|
|
|
|
/**
|
|
* 자재/요청 스키마
|
|
*/
|
|
/**
|
|
* @OA\Schema(
|
|
* schema="MaterialAttribute",
|
|
* type="object",
|
|
* description="규격 정보 한 항목",
|
|
*
|
|
* @OA\Property(property="label", type="string", example="두께"),
|
|
* @OA\Property(property="value", type="string", example="10"),
|
|
* @OA\Property(property="unit", type="string", example="T")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="Material",
|
|
* type="object",
|
|
* description="자재 상세",
|
|
* required={"id","tenant_id","name","item_name","unit"},
|
|
*
|
|
* @OA\Property(property="id", type="integer", example=101),
|
|
* @OA\Property(property="tenant_id", type="integer", example=1),
|
|
* @OA\Property(property="category_id", type="integer", nullable=true, example=3),
|
|
* @OA\Property(property="name", type="string", example="철판"),
|
|
* @OA\Property(property="item_name", type="string", example="철판 10T 150CM"),
|
|
* @OA\Property(property="specification", type="string", nullable=true, example="두께 10T, 길이 150CM"),
|
|
* @OA\Property(property="material_code", type="string", nullable=true, example=null),
|
|
* @OA\Property(property="unit", type="string", example="EA"),
|
|
* @OA\Property(property="is_inspection", type="string", enum={"Y","N"}, example="N"),
|
|
* @OA\Property(property="search_tag", type="string", nullable=true, example="철판, 판재, 금속"),
|
|
* @OA\Property(property="remarks", type="string", nullable=true, example="비고 메모"),
|
|
* @OA\Property(
|
|
* property="attributes",
|
|
* type="array",
|
|
* nullable=true,
|
|
*
|
|
* @OA\Items(ref="#/components/schemas/MaterialAttribute")
|
|
* ),
|
|
*
|
|
* @OA\Property(
|
|
* property="options",
|
|
* type="object",
|
|
* nullable=true,
|
|
* example={"manufacturer":"ACME","color":"SILVER"}
|
|
* ),
|
|
* @OA\Property(property="created_by", type="integer", example=12),
|
|
* @OA\Property(property="updated_by", type="integer", nullable=true, example=12),
|
|
* @OA\Property(property="created_at", type="string", format="date-time", example="2025-08-21 10:00:00"),
|
|
* @OA\Property(property="updated_at", type="string", format="date-time", example="2025-08-21 10:00:00")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="MaterialBrief",
|
|
* type="object",
|
|
* description="자재 요약",
|
|
* required={"id","name","item_name","unit"},
|
|
*
|
|
* @OA\Property(property="id", type="integer", example=101),
|
|
* @OA\Property(property="category_id", type="integer", nullable=true, example=3),
|
|
* @OA\Property(property="name", type="string", example="철판"),
|
|
* @OA\Property(property="item_name", type="string", example="철판 10T 150CM"),
|
|
* @OA\Property(property="unit", type="string", example="EA")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="MaterialList",
|
|
* type="array",
|
|
*
|
|
* @OA\Items(ref="#/components/schemas/MaterialBrief")
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="MaterialIndexParams",
|
|
* type="object",
|
|
*
|
|
* @OA\Property(property="q", type="string", nullable=true, example="알루미늄"),
|
|
* @OA\Property(property="category", type="integer", nullable=true, example=3),
|
|
* @OA\Property(property="page", type="integer", nullable=true, example=1),
|
|
* @OA\Property(property="per_page", type="integer", nullable=true, example=20)
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="MaterialCreateRequest",
|
|
* type="object",
|
|
* required={"name","unit"},
|
|
*
|
|
* @OA\Property(property="category_id", type="integer", nullable=true, example=3),
|
|
* @OA\Property(property="name", type="string", example="철판"),
|
|
* @OA\Property(property="unit", type="string", example="EA"),
|
|
* @OA\Property(property="is_inspection", type="string", enum={"Y","N"}, example="N"),
|
|
* @OA\Property(property="search_tag", type="string", nullable=true, example="철판, 판재, 금속"),
|
|
* @OA\Property(property="remarks", type="string", nullable=true, example="비고 메모"),
|
|
* @OA\Property(
|
|
* property="attributes",
|
|
* type="array",
|
|
* nullable=true,
|
|
*
|
|
* @OA\Items(ref="#/components/schemas/MaterialAttribute")
|
|
* ),
|
|
*
|
|
* @OA\Property(
|
|
* property="options",
|
|
* type="object",
|
|
* nullable=true,
|
|
* example={"manufacturer":"ACME","color":"SILVER"}
|
|
* ),
|
|
* @OA\Property(property="material_code", type="string", nullable=true, example=null),
|
|
* @OA\Property(property="specification", type="string", nullable=true, example=null)
|
|
* )
|
|
*
|
|
* @OA\Schema(
|
|
* schema="MaterialUpdateRequest",
|
|
* type="object",
|
|
*
|
|
* @OA\Property(property="category_id", type="integer", nullable=true, example=3),
|
|
* @OA\Property(property="name", type="string", nullable=true, example="철판(개선)"),
|
|
* @OA\Property(property="unit", type="string", nullable=true, example="KG"),
|
|
* @OA\Property(property="is_inspection", type="string", enum={"Y","N"}, nullable=true, example="Y"),
|
|
* @OA\Property(property="search_tag", type="string", nullable=true, example="철판, 금속"),
|
|
* @OA\Property(property="remarks", type="string", nullable=true, example="비고 변경"),
|
|
* @OA\Property(
|
|
* property="attributes",
|
|
* type="array",
|
|
* nullable=true,
|
|
*
|
|
* @OA\Items(ref="#/components/schemas/MaterialAttribute")
|
|
* ),
|
|
*
|
|
* @OA\Property(
|
|
* property="options",
|
|
* type="object",
|
|
* nullable=true,
|
|
* example={"manufacturer":"ACME","color":"BLACK"}
|
|
* ),
|
|
* @OA\Property(property="material_code", type="string", nullable=true, example="MAT-0002"),
|
|
* @OA\Property(property="specification", type="string", nullable=true, example="두께 12T, 길이 180CM")
|
|
* )
|
|
*/
|
|
class MaterialApi
|
|
{
|
|
/**
|
|
* @OA\Get(
|
|
* path="/api/v1/products/materials",
|
|
* summary="자재 목록 조회",
|
|
* description="자재 목록을 페이징으로 반환합니다. (q로 코드/이름/태그 검색, category로 분류 필터)",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\Parameter(ref="#/components/parameters/Page"),
|
|
* @OA\Parameter(ref="#/components/parameters/Size"),
|
|
* @OA\Parameter(name="q", in="query", required=false, @OA\Schema(type="string"), description="검색어(이름/코드/태그 등)"),
|
|
* @OA\Parameter(name="category", in="query", required=false, @OA\Schema(type="integer"), description="카테고리 ID"),
|
|
*
|
|
* @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="per_page", type="integer", example=20),
|
|
* @OA\Property(property="total", type="integer", example=2),
|
|
* @OA\Property(property="data", ref="#/components/schemas/MaterialList")
|
|
* ))
|
|
* }
|
|
* )
|
|
* )
|
|
* )
|
|
*/
|
|
public function index() {}
|
|
|
|
/**
|
|
* @OA\Post(
|
|
* path="/api/v1/products/materials",
|
|
* summary="자재 등록",
|
|
* description="자재를 등록합니다. item_name/specification은 name+attributes를 기반으로 서버에서 자동 생성됩니다.",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/MaterialCreateRequest")),
|
|
*
|
|
* @OA\Response(
|
|
* response=200, description="자재 등록 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Material"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(response=422, description="검증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function store() {}
|
|
|
|
/**
|
|
* @OA\Get(
|
|
* path="/api/v1/products/materials/{id}",
|
|
* summary="자재 단건 조회",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer", example=101)),
|
|
*
|
|
* @OA\Response(
|
|
* response=200, description="자재 단건 조회 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Material"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(response=404, description="데이터 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function show() {}
|
|
|
|
/**
|
|
* @OA\Put(
|
|
* path="/api/v1/products/materials/{id}",
|
|
* summary="자재 수정(전체)",
|
|
* description="자재를 수정합니다. name/attributes 변경 시 item_name/specification이 서버에서 재계산됩니다.",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer", example=101)),
|
|
*
|
|
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/MaterialUpdateRequest")),
|
|
*
|
|
* @OA\Response(
|
|
* response=200, description="자재 수정 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Material"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(response=404, description="데이터 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
|
* @OA\Response(response=422, description="검증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function updatePut() {}
|
|
|
|
/**
|
|
* @OA\Patch(
|
|
* path="/api/v1/products/materials/{id}",
|
|
* summary="자재 부분 수정",
|
|
* description="자재의 일부 필드를 수정합니다. name/attributes 변경 시 item_name/specification이 서버에서 재계산됩니다.",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer", example=101)),
|
|
*
|
|
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/MaterialUpdateRequest")),
|
|
*
|
|
* @OA\Response(
|
|
* response=200, description="자재 수정 성공",
|
|
*
|
|
* @OA\JsonContent(
|
|
* allOf={
|
|
*
|
|
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
|
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Material"))
|
|
* }
|
|
* )
|
|
* ),
|
|
*
|
|
* @OA\Response(response=404, description="데이터 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
|
|
* @OA\Response(response=422, description="검증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function updatePatch() {}
|
|
|
|
/**
|
|
* @OA\Delete(
|
|
* path="/api/v1/products/materials/{id}",
|
|
* summary="자재 삭제",
|
|
* description="자재를 소프트 삭제합니다.",
|
|
* tags={"Material"},
|
|
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
|
|
*
|
|
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer", example=101)),
|
|
*
|
|
* @OA\Response(response=200, description="자재 삭제 성공", @OA\JsonContent(ref="#/components/schemas/ApiResponse")),
|
|
* @OA\Response(response=404, description="데이터 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
|
* )
|
|
*/
|
|
public function destroy() {}
|
|
}
|