feat: ClientGroup 및 Pricing API 완성 및 Swagger 문서 작성
- ClientGroupService 구현: 고객 그룹 관리 비즈니스 로직 (CRUD + toggle) - ClientGroupController 구현: 6개 REST API 엔드포인트 - PricingController 구현: 5개 가격 관리 API 엔드포인트 - routes/api.php에 client-groups, pricing 라우트 등록 - ClientGroupApi.php Swagger 문서 작성 (OpenAPI 3.0) - PricingApi.php Swagger 문서 작성 (OpenAPI 3.0) - l5-swagger 재생성 완료 추가된 파일: - app/Services/ClientGroupService.php - app/Http/Controllers/Api/V1/ClientGroupController.php - app/Http/Controllers/Api/V1/PricingController.php - app/Swagger/v1/ClientGroupApi.php - app/Swagger/v1/PricingApi.php 수정된 파일: - routes/api.php (라우트 11개 추가) - CURRENT_WORKS.md (작업 내용 문서화) API 엔드포인트: - GET/POST/PUT/DELETE /api/v1/client-groups - GET/POST /api/v1/pricing (show, bulk, upsert 포함)
This commit is contained in:
72
app/Http/Controllers/Api/V1/ClientGroupController.php
Normal file
72
app/Http/Controllers/Api/V1/ClientGroupController.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ClientGroupService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ClientGroupController extends Controller
|
||||
{
|
||||
protected ClientGroupService $service;
|
||||
|
||||
public function __construct(ClientGroupService $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $this->service->index($request->all());
|
||||
|
||||
return ['data' => $data, 'message' => __('message.fetched')];
|
||||
});
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$data = $this->service->show($id);
|
||||
|
||||
return ['data' => $data, 'message' => __('message.fetched')];
|
||||
});
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $this->service->store($request->all());
|
||||
|
||||
return ['data' => $data, 'message' => __('message.created')];
|
||||
});
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $id) {
|
||||
$data = $this->service->update($id, $request->all());
|
||||
|
||||
return ['data' => $data, 'message' => __('message.updated')];
|
||||
});
|
||||
}
|
||||
|
||||
public function destroy(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$this->service->destroy($id);
|
||||
|
||||
return ['data' => null, 'message' => __('message.deleted')];
|
||||
});
|
||||
}
|
||||
|
||||
public function toggle(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$data = $this->service->toggle($id);
|
||||
|
||||
return ['data' => $data, 'message' => __('message.updated')];
|
||||
});
|
||||
}
|
||||
}
|
||||
96
app/Http/Controllers/Api/V1/PricingController.php
Normal file
96
app/Http/Controllers/Api/V1/PricingController.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Pricing\PricingService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PricingController extends Controller
|
||||
{
|
||||
protected PricingService $service;
|
||||
|
||||
public function __construct(PricingService $service)
|
||||
{
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* 가격 이력 목록 조회
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$filters = $request->only([
|
||||
'item_type_code',
|
||||
'item_id',
|
||||
'price_type_code',
|
||||
'client_group_id',
|
||||
'date',
|
||||
]);
|
||||
$perPage = (int) ($request->input('size') ?? 15);
|
||||
|
||||
$data = $this->service->listPrices($filters, $perPage);
|
||||
|
||||
return ['data' => $data, 'message' => __('message.fetched')];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 항목 가격 조회
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$itemType = $request->input('item_type'); // PRODUCT | MATERIAL
|
||||
$itemId = (int) $request->input('item_id');
|
||||
$clientId = $request->input('client_id') ? (int) $request->input('client_id') : null;
|
||||
$date = $request->input('date') ?? null;
|
||||
|
||||
$result = $this->service->getItemPrice($itemType, $itemId, $clientId, $date);
|
||||
|
||||
return ['data' => $result, 'message' => __('message.fetched')];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 여러 항목 일괄 가격 조회
|
||||
*/
|
||||
public function bulk(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$items = $request->input('items'); // [['item_type' => 'PRODUCT', 'item_id' => 1], ...]
|
||||
$clientId = $request->input('client_id') ? (int) $request->input('client_id') : null;
|
||||
$date = $request->input('date') ?? null;
|
||||
|
||||
$result = $this->service->getBulkItemPrices($items, $clientId, $date);
|
||||
|
||||
return ['data' => $result, 'message' => __('message.fetched')];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 가격 등록/수정
|
||||
*/
|
||||
public function upsert(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
$data = $this->service->upsertPrice($request->all());
|
||||
|
||||
return ['data' => $data, 'message' => __('message.created')];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 가격 삭제
|
||||
*/
|
||||
public function destroy(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
$this->service->deletePrice($id);
|
||||
|
||||
return ['data' => null, 'message' => __('message.deleted')];
|
||||
});
|
||||
}
|
||||
}
|
||||
167
app/Services/ClientGroupService.php
Normal file
167
app/Services/ClientGroupService.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Orders\ClientGroup;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class ClientGroupService extends Service
|
||||
{
|
||||
/** 목록(검색/페이징) */
|
||||
public function index(array $params)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
$page = (int) ($params['page'] ?? 1);
|
||||
$size = (int) ($params['size'] ?? 20);
|
||||
$q = trim((string) ($params['q'] ?? ''));
|
||||
$onlyActive = $params['only_active'] ?? null;
|
||||
|
||||
$query = ClientGroup::query()->where('tenant_id', $tenantId);
|
||||
|
||||
if ($q !== '') {
|
||||
$query->where(function ($qq) use ($q) {
|
||||
$qq->where('group_name', 'like', "%{$q}%")
|
||||
->orWhere('group_code', 'like', "%{$q}%");
|
||||
});
|
||||
}
|
||||
|
||||
if ($onlyActive !== null) {
|
||||
$query->where('is_active', $onlyActive ? 1 : 0);
|
||||
}
|
||||
|
||||
$query->orderBy('group_code')->orderBy('id');
|
||||
|
||||
return $query->paginate($size, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
/** 단건 */
|
||||
public function show(int $id)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$group = ClientGroup::where('tenant_id', $tenantId)->find($id);
|
||||
if (! $group) {
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
/** 생성 */
|
||||
public function store(array $params)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$uid = $this->apiUserId();
|
||||
|
||||
$v = Validator::make($params, [
|
||||
'group_code' => 'required|string|max:30',
|
||||
'group_name' => 'required|string|max:100',
|
||||
'price_rate' => 'required|numeric|min:0|max:99.9999',
|
||||
'is_active' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
throw new BadRequestHttpException($v->errors()->first());
|
||||
}
|
||||
|
||||
$data = $v->validated();
|
||||
|
||||
// group_code 중복 검사
|
||||
$exists = ClientGroup::where('tenant_id', $tenantId)
|
||||
->where('group_code', $data['group_code'])
|
||||
->exists();
|
||||
if ($exists) {
|
||||
throw new BadRequestHttpException(__('error.duplicate_code'));
|
||||
}
|
||||
|
||||
$data['tenant_id'] = $tenantId;
|
||||
$data['is_active'] = $data['is_active'] ?? 1;
|
||||
$data['created_by'] = $uid;
|
||||
|
||||
return ClientGroup::create($data);
|
||||
}
|
||||
|
||||
/** 수정 */
|
||||
public function update(int $id, array $params)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$uid = $this->apiUserId();
|
||||
|
||||
$group = ClientGroup::where('tenant_id', $tenantId)->find($id);
|
||||
if (! $group) {
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
$v = Validator::make($params, [
|
||||
'group_code' => 'sometimes|required|string|max:30',
|
||||
'group_name' => 'sometimes|required|string|max:100',
|
||||
'price_rate' => 'sometimes|required|numeric|min:0|max:99.9999',
|
||||
'is_active' => 'nullable|boolean',
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
throw new BadRequestHttpException($v->errors()->first());
|
||||
}
|
||||
|
||||
$payload = $v->validated();
|
||||
|
||||
// group_code 변경 시 중복 검사
|
||||
if (isset($payload['group_code']) && $payload['group_code'] !== $group->group_code) {
|
||||
$exists = ClientGroup::where('tenant_id', $tenantId)
|
||||
->where('group_code', $payload['group_code'])
|
||||
->exists();
|
||||
if ($exists) {
|
||||
throw new BadRequestHttpException(__('error.duplicate_code'));
|
||||
}
|
||||
}
|
||||
|
||||
$payload['updated_by'] = $uid;
|
||||
|
||||
$group->update($payload);
|
||||
|
||||
return $group->refresh();
|
||||
}
|
||||
|
||||
/** 삭제 */
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$uid = $this->apiUserId();
|
||||
|
||||
$group = ClientGroup::where('tenant_id', $tenantId)->find($id);
|
||||
if (! $group) {
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
// 해당 그룹에 속한 고객이 있는지 검사
|
||||
if ($group->clients()->exists()) {
|
||||
throw new BadRequestHttpException(__('error.has_clients'));
|
||||
}
|
||||
|
||||
$group->deleted_by = $uid;
|
||||
$group->save();
|
||||
$group->delete();
|
||||
|
||||
return 'success';
|
||||
}
|
||||
|
||||
/** 활성/비활성 토글 */
|
||||
public function toggle(int $id)
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$uid = $this->apiUserId();
|
||||
|
||||
$group = ClientGroup::where('tenant_id', $tenantId)->find($id);
|
||||
if (! $group) {
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
$group->is_active = $group->is_active ? 0 : 1;
|
||||
$group->updated_by = $uid;
|
||||
$group->save();
|
||||
|
||||
return $group->refresh();
|
||||
}
|
||||
}
|
||||
176
app/Swagger/v1/ClientGroupApi.php
Normal file
176
app/Swagger/v1/ClientGroupApi.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace App\Swagger\v1;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="ClientGroup", description="고객 그룹 관리")
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ClientGroup",
|
||||
* type="object",
|
||||
* required={"id","group_code","group_name","price_rate"},
|
||||
* @OA\Property(property="id", type="integer", example=1),
|
||||
* @OA\Property(property="tenant_id", type="integer", example=1),
|
||||
* @OA\Property(property="group_code", type="string", example="VIP"),
|
||||
* @OA\Property(property="group_name", type="string", example="VIP 고객"),
|
||||
* @OA\Property(property="price_rate", type="number", format="decimal", example=0.9, description="가격 배율 (1.0=기준가, 0.9=90%, 1.1=110%)"),
|
||||
* @OA\Property(property="is_active", type="boolean", example=true),
|
||||
* @OA\Property(property="created_at", type="string", example="2025-10-01 12:00:00"),
|
||||
* @OA\Property(property="updated_at", type="string", example="2025-10-01 12:00:00")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ClientGroupPagination",
|
||||
* type="object",
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* @OA\Items(ref="#/components/schemas/ClientGroup")
|
||||
* ),
|
||||
* @OA\Property(property="first_page_url", type="string", example="/api/v1/client-groups?page=1"),
|
||||
* @OA\Property(property="from", type="integer", example=1),
|
||||
* @OA\Property(property="last_page", type="integer", example=3),
|
||||
* @OA\Property(property="last_page_url", type="string", example="/api/v1/client-groups?page=3"),
|
||||
* @OA\Property(
|
||||
* property="links",
|
||||
* type="array",
|
||||
* @OA\Items(type="object",
|
||||
* @OA\Property(property="url", type="string", nullable=true, example=null),
|
||||
* @OA\Property(property="label", type="string", example="« Previous"),
|
||||
* @OA\Property(property="active", type="boolean", example=false)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(property="next_page_url", type="string", nullable=true, example="/api/v1/client-groups?page=2"),
|
||||
* @OA\Property(property="path", type="string", example="/api/v1/client-groups"),
|
||||
* @OA\Property(property="per_page", type="integer", example=20),
|
||||
* @OA\Property(property="prev_page_url", type="string", nullable=true, example=null),
|
||||
* @OA\Property(property="to", type="integer", example=20),
|
||||
* @OA\Property(property="total", type="integer", example=50)
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ClientGroupCreateRequest",
|
||||
* type="object",
|
||||
* required={"group_code","group_name","price_rate"},
|
||||
* @OA\Property(property="group_code", type="string", maxLength=30, example="VIP", description="그룹 코드"),
|
||||
* @OA\Property(property="group_name", type="string", maxLength=100, example="VIP 고객", description="그룹명"),
|
||||
* @OA\Property(property="price_rate", type="number", format="decimal", example=0.9, description="가격 배율 (1.0=기준가)"),
|
||||
* @OA\Property(property="is_active", type="boolean", example=true, description="활성 여부")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="ClientGroupUpdateRequest",
|
||||
* type="object",
|
||||
* @OA\Property(property="group_code", type="string", maxLength=30),
|
||||
* @OA\Property(property="group_name", type="string", maxLength=100),
|
||||
* @OA\Property(property="price_rate", type="number", format="decimal"),
|
||||
* @OA\Property(property="is_active", type="boolean")
|
||||
* )
|
||||
*/
|
||||
class ClientGroupApi
|
||||
{
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/client-groups",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="고객 그룹 목록",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="page", in="query", @OA\Schema(type="integer", example=1)),
|
||||
* @OA\Parameter(name="size", in="query", @OA\Schema(type="integer", example=20)),
|
||||
* @OA\Parameter(name="q", in="query", description="그룹 코드/이름 검색", @OA\Schema(type="string")),
|
||||
* @OA\Parameter(name="only_active", in="query", @OA\Schema(type="boolean")),
|
||||
* @OA\Response(response=200, description="조회 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ClientGroupPagination"))
|
||||
* })
|
||||
* ),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function index() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/client-groups/{id}",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="고객 그룹 단건 조회",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="id", in="path", required=true, @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/ClientGroup"))
|
||||
* })
|
||||
* ),
|
||||
* @OA\Response(response=404, description="데이터 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function show() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/client-groups",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="고객 그룹 생성",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/ClientGroupCreateRequest")),
|
||||
* @OA\Response(response=200, description="생성 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ClientGroup"))
|
||||
* })
|
||||
* ),
|
||||
* @OA\Response(response=400, description="검증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function store() {}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* path="/api/v1/client-groups/{id}",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="고객 그룹 수정",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
|
||||
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/ClientGroupUpdateRequest")),
|
||||
* @OA\Response(response=200, description="수정 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/ClientGroup"))
|
||||
* })
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function update() {}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/api/v1/client-groups/{id}",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="고객 그룹 삭제(soft)",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
|
||||
* @OA\Response(response=200, description="삭제 성공", @OA\JsonContent(ref="#/components/schemas/ApiResponse"))
|
||||
* )
|
||||
*/
|
||||
public function destroy() {}
|
||||
|
||||
/**
|
||||
* @OA\Patch(
|
||||
* path="/api/v1/client-groups/{id}/toggle",
|
||||
* tags={"ClientGroup"},
|
||||
* summary="활성/비활성 토글",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="id", in="path", required=true, @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/ClientGroup"))
|
||||
* })
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function toggle() {}
|
||||
}
|
||||
204
app/Swagger/v1/PricingApi.php
Normal file
204
app/Swagger/v1/PricingApi.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Swagger\v1;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="Pricing", description="가격 이력 관리")
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="PriceHistory",
|
||||
* type="object",
|
||||
* required={"id","item_type_code","item_id","price_type_code","price","started_at"},
|
||||
* @OA\Property(property="id", type="integer", example=1),
|
||||
* @OA\Property(property="tenant_id", type="integer", example=1),
|
||||
* @OA\Property(property="item_type_code", type="string", enum={"PRODUCT","MATERIAL"}, example="PRODUCT", description="항목 유형"),
|
||||
* @OA\Property(property="item_id", type="integer", example=10, description="제품/자재 ID"),
|
||||
* @OA\Property(property="price_type_code", type="string", enum={"SALE","PURCHASE"}, example="SALE", description="가격 유형"),
|
||||
* @OA\Property(property="client_group_id", type="integer", nullable=true, example=1, description="고객 그룹 ID (NULL=기본 가격)"),
|
||||
* @OA\Property(property="price", type="number", format="decimal", example=50000.00),
|
||||
* @OA\Property(property="started_at", type="string", format="date", example="2025-01-01"),
|
||||
* @OA\Property(property="ended_at", type="string", format="date", nullable=true, example="2025-12-31"),
|
||||
* @OA\Property(property="created_at", type="string", example="2025-10-01 12:00:00"),
|
||||
* @OA\Property(property="updated_at", type="string", example="2025-10-01 12:00:00")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="PriceHistoryPagination",
|
||||
* type="object",
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* @OA\Items(ref="#/components/schemas/PriceHistory")
|
||||
* ),
|
||||
* @OA\Property(property="first_page_url", type="string", example="/api/v1/pricing?page=1"),
|
||||
* @OA\Property(property="from", type="integer", example=1),
|
||||
* @OA\Property(property="last_page", type="integer", example=3),
|
||||
* @OA\Property(property="last_page_url", type="string", example="/api/v1/pricing?page=3"),
|
||||
* @OA\Property(
|
||||
* property="links",
|
||||
* type="array",
|
||||
* @OA\Items(type="object",
|
||||
* @OA\Property(property="url", type="string", nullable=true, example=null),
|
||||
* @OA\Property(property="label", type="string", example="« Previous"),
|
||||
* @OA\Property(property="active", type="boolean", example=false)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(property="next_page_url", type="string", nullable=true, example="/api/v1/pricing?page=2"),
|
||||
* @OA\Property(property="path", type="string", example="/api/v1/pricing"),
|
||||
* @OA\Property(property="per_page", type="integer", example=15),
|
||||
* @OA\Property(property="prev_page_url", type="string", nullable=true, example=null),
|
||||
* @OA\Property(property="to", type="integer", example=15),
|
||||
* @OA\Property(property="total", type="integer", example=50)
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="PriceUpsertRequest",
|
||||
* type="object",
|
||||
* required={"item_type_code","item_id","price_type_code","price","started_at"},
|
||||
* @OA\Property(property="item_type_code", type="string", enum={"PRODUCT","MATERIAL"}, example="PRODUCT"),
|
||||
* @OA\Property(property="item_id", type="integer", example=10),
|
||||
* @OA\Property(property="price_type_code", type="string", enum={"SALE","PURCHASE"}, example="SALE"),
|
||||
* @OA\Property(property="client_group_id", type="integer", nullable=true, example=1, description="NULL=기본 가격"),
|
||||
* @OA\Property(property="price", type="number", format="decimal", example=50000.00),
|
||||
* @OA\Property(property="started_at", type="string", format="date", example="2025-01-01"),
|
||||
* @OA\Property(property="ended_at", type="string", format="date", nullable=true, example="2025-12-31")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="PriceQueryResult",
|
||||
* type="object",
|
||||
* @OA\Property(property="price", type="number", format="decimal", nullable=true, example=50000.00),
|
||||
* @OA\Property(property="price_history_id", type="integer", nullable=true, example=1),
|
||||
* @OA\Property(property="client_group_id", type="integer", nullable=true, example=1),
|
||||
* @OA\Property(property="warning", type="string", nullable=true, example="가격을 찾을 수 없습니다")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="BulkPriceQueryRequest",
|
||||
* type="object",
|
||||
* required={"items"},
|
||||
* @OA\Property(
|
||||
* property="items",
|
||||
* type="array",
|
||||
* @OA\Items(type="object",
|
||||
* @OA\Property(property="item_type", type="string", enum={"PRODUCT","MATERIAL"}, example="PRODUCT"),
|
||||
* @OA\Property(property="item_id", type="integer", example=10)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(property="client_id", type="integer", nullable=true, example=5),
|
||||
* @OA\Property(property="date", type="string", format="date", nullable=true, example="2025-10-13")
|
||||
* )
|
||||
*
|
||||
* @OA\Schema(
|
||||
* schema="BulkPriceQueryResult",
|
||||
* type="object",
|
||||
* @OA\Property(
|
||||
* property="prices",
|
||||
* type="array",
|
||||
* @OA\Items(type="object",
|
||||
* @OA\Property(property="item_type", type="string", example="PRODUCT"),
|
||||
* @OA\Property(property="item_id", type="integer", example=10),
|
||||
* @OA\Property(property="price", type="number", nullable=true, example=50000.00),
|
||||
* @OA\Property(property="price_history_id", type="integer", nullable=true, example=1),
|
||||
* @OA\Property(property="client_group_id", type="integer", nullable=true, example=1)
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(property="warnings", type="array", @OA\Items(type="string"))
|
||||
* )
|
||||
*/
|
||||
class PricingApi
|
||||
{
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/pricing",
|
||||
* tags={"Pricing"},
|
||||
* summary="가격 이력 목록",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="item_type_code", in="query", @OA\Schema(type="string", enum={"PRODUCT","MATERIAL"})),
|
||||
* @OA\Parameter(name="item_id", in="query", @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="price_type_code", in="query", @OA\Schema(type="string", enum={"SALE","PURCHASE"})),
|
||||
* @OA\Parameter(name="client_group_id", in="query", @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="date", in="query", description="특정 날짜 기준 유효한 가격", @OA\Schema(type="string", format="date")),
|
||||
* @OA\Parameter(name="size", in="query", @OA\Schema(type="integer", example=15)),
|
||||
* @OA\Response(response=200, description="조회 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/PriceHistoryPagination"))
|
||||
* })
|
||||
* ),
|
||||
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function index() {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/api/v1/pricing/show",
|
||||
* tags={"Pricing"},
|
||||
* summary="단일 항목 가격 조회",
|
||||
* description="특정 제품/자재의 현재 유효한 가격 조회",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="item_type", in="query", required=true, @OA\Schema(type="string", enum={"PRODUCT","MATERIAL"})),
|
||||
* @OA\Parameter(name="item_id", in="query", required=true, @OA\Schema(type="integer")),
|
||||
* @OA\Parameter(name="client_id", in="query", @OA\Schema(type="integer"), description="고객 ID (고객 그룹별 가격 적용)"),
|
||||
* @OA\Parameter(name="date", in="query", @OA\Schema(type="string", format="date"), description="기준일 (미지정시 오늘)"),
|
||||
* @OA\Response(response=200, description="조회 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/PriceQueryResult"))
|
||||
* })
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function show() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/pricing/bulk",
|
||||
* tags={"Pricing"},
|
||||
* summary="여러 항목 일괄 가격 조회",
|
||||
* description="여러 제품/자재의 가격을 한 번에 조회",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/BulkPriceQueryRequest")),
|
||||
* @OA\Response(response=200, description="조회 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/BulkPriceQueryResult"))
|
||||
* })
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function bulk() {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/api/v1/pricing/upsert",
|
||||
* tags={"Pricing"},
|
||||
* summary="가격 등록/수정",
|
||||
* description="가격 이력 등록 (동일 조건 존재 시 업데이트)",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/PriceUpsertRequest")),
|
||||
* @OA\Response(response=200, description="저장 성공",
|
||||
* @OA\JsonContent(allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/PriceHistory"))
|
||||
* })
|
||||
* ),
|
||||
* @OA\Response(response=400, description="검증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
|
||||
* )
|
||||
*/
|
||||
public function upsert() {}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/api/v1/pricing/{id}",
|
||||
* tags={"Pricing"},
|
||||
* summary="가격 이력 삭제(soft)",
|
||||
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
|
||||
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
|
||||
* @OA\Response(response=200, description="삭제 성공", @OA\JsonContent(ref="#/components/schemas/ApiResponse"))
|
||||
* )
|
||||
*/
|
||||
public function destroy() {}
|
||||
}
|
||||
Reference in New Issue
Block a user