Revert "feat: DB 연결 오버라이딩 및 대시보드 통계 위젯 추가"
This reverts commit bf8036a64b.
This commit is contained in:
@@ -1,335 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Design;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\BomConditionRuleService;
|
||||
use App\Http\Requests\Api\V1\Design\BomConditionRuleFormRequest;
|
||||
use App\Http\Requests\Api\V1\BomConditionRule\IndexBomConditionRuleRequest;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="BOM Condition Rules", description="BOM condition rule management APIs")
|
||||
*/
|
||||
class BomConditionRuleController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected BomConditionRuleService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/design/models/{modelId}/condition-rules",
|
||||
* summary="Get BOM condition rules",
|
||||
* description="Retrieve all condition rules for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="page",
|
||||
* description="Page number for pagination",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="per_page",
|
||||
* description="Items per page",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=20)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="search",
|
||||
* description="Search by rule name or condition",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="string", example="bracket_selection")
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="priority",
|
||||
* description="Filter by priority level",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="BOM condition rules retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* @OA\Items(ref="#/components/schemas/BomConditionRuleResource")
|
||||
* ),
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(property="last_page", type="integer", example=2),
|
||||
* @OA\Property(property="per_page", type="integer", example=20),
|
||||
* @OA\Property(property="total", type="integer", example=30)
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function index(IndexBomConditionRuleRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->getModelConditionRules($modelId, $request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/condition-rules",
|
||||
* summary="Create BOM condition rule",
|
||||
* description="Create a new condition rule for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/CreateBomConditionRuleRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=201,
|
||||
* description="BOM condition rule created successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/BomConditionRuleResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401)
|
||||
* )
|
||||
*/
|
||||
public function store(BomConditionRuleFormRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->createConditionRule($modelId, $request->validated());
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* path="/v1/design/models/{modelId}/condition-rules/{ruleId}",
|
||||
* summary="Update BOM condition rule",
|
||||
* description="Update a specific BOM condition rule",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="ruleId",
|
||||
* description="Rule ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/UpdateBomConditionRuleRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="BOM condition rule updated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/BomConditionRuleResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function update(BomConditionRuleFormRequest $request, int $modelId, int $ruleId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId, $ruleId) {
|
||||
return $this->service->updateConditionRule($modelId, $ruleId, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/v1/design/models/{modelId}/condition-rules/{ruleId}",
|
||||
* summary="Delete BOM condition rule",
|
||||
* description="Delete a specific BOM condition rule",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="ruleId",
|
||||
* description="Rule ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="BOM condition rule deleted successfully",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ApiResponse")
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function destroy(int $modelId, int $ruleId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId, $ruleId) {
|
||||
$this->service->deleteConditionRule($modelId, $ruleId);
|
||||
return null;
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/condition-rules/{ruleId}/validate",
|
||||
* summary="Validate BOM condition rule",
|
||||
* description="Validate condition rule expression and logic",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="ruleId",
|
||||
* description="Rule ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Condition rule validation result",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(property="is_valid", type="boolean", example=true),
|
||||
* @OA\Property(
|
||||
* property="validation_errors",
|
||||
* type="array",
|
||||
* @OA\Items(type="string", example="Invalid condition syntax")
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="tested_scenarios",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="scenario", type="string", example="W0=1000, H0=800"),
|
||||
* @OA\Property(property="result", type="boolean", example=true)
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function validate(int $modelId, int $ruleId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId, $ruleId) {
|
||||
return $this->service->validateConditionRule($modelId, $ruleId);
|
||||
}, __('message.condition_rule.validated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/condition-rules/reorder",
|
||||
* summary="Reorder BOM condition rules",
|
||||
* description="Change the priority order of condition rules",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Condition Rules"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="rule_orders",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="rule_id", type="integer", example=1),
|
||||
* @OA\Property(property="priority", type="integer", example=1)
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="BOM condition rules reordered successfully",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ApiResponse")
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function reorder(int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId) {
|
||||
$ruleOrders = request()->input('rule_orders', []);
|
||||
$this->service->reorderConditionRules($modelId, $ruleOrders);
|
||||
return null;
|
||||
}, __('message.reordered'));
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Design;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\BomResolverService;
|
||||
use App\Http\Requests\Api\V1\Design\BomResolverFormRequest;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="BOM Resolver", description="BOM resolution and preview APIs")
|
||||
*/
|
||||
class BomResolverController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected BomResolverService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/resolve-bom",
|
||||
* summary="Resolve BOM preview",
|
||||
* description="Generate real-time BOM preview based on input parameters without creating actual products",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Resolver"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/ResolvePreviewRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="BOM preview generated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/BomPreviewResponse")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function resolveBom(BomResolverFormRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->generatePreview($modelId, $request->validated());
|
||||
}, __('message.bom.preview_generated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/validate-parameters",
|
||||
* summary="Validate model parameters",
|
||||
* description="Validate input parameters against model constraints before BOM resolution",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Resolver"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="input_parameters",
|
||||
* description="Input parameter values to validate",
|
||||
* type="object",
|
||||
* additionalProperties=@OA\Property(oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string"),
|
||||
* @OA\Schema(type="boolean")
|
||||
* }),
|
||||
* example={"W0": 1000, "H0": 800, "installation_type": "A"}
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Parameter validation result",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(property="is_valid", type="boolean", example=true),
|
||||
* @OA\Property(
|
||||
* property="validation_errors",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="parameter", type="string", example="W0"),
|
||||
* @OA\Property(property="error", type="string", example="Value must be between 500 and 2000")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="warnings",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="parameter", type="string", example="H0"),
|
||||
* @OA\Property(property="warning", type="string", example="Recommended range is 600-1500")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function validateParameters(int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId) {
|
||||
$inputParameters = request()->input('input_parameters', []);
|
||||
return $this->service->validateParameters($modelId, $inputParameters);
|
||||
}, __('message.parameters.validated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/design/models/{modelId}/parameter-schema",
|
||||
* summary="Get model parameter schema",
|
||||
* description="Retrieve the input parameter schema for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Resolver"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model parameter schema retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(
|
||||
* property="input_parameters",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="name", type="string", example="W0"),
|
||||
* @OA\Property(property="label", type="string", example="Width"),
|
||||
* @OA\Property(property="data_type", type="string", example="INTEGER"),
|
||||
* @OA\Property(property="unit", type="string", example="mm"),
|
||||
* @OA\Property(property="min_value", type="number", example=500),
|
||||
* @OA\Property(property="max_value", type="number", example=3000),
|
||||
* @OA\Property(property="default_value", type="string", example="1000"),
|
||||
* @OA\Property(property="is_required", type="boolean", example=true),
|
||||
* @OA\Property(property="description", type="string", example="Product width in millimeters")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="output_parameters",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="name", type="string", example="W1"),
|
||||
* @OA\Property(property="label", type="string", example="Actual Width"),
|
||||
* @OA\Property(property="data_type", type="string", example="INTEGER"),
|
||||
* @OA\Property(property="unit", type="string", example="mm"),
|
||||
* @OA\Property(property="description", type="string", example="Calculated actual width")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function getParameterSchema(int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId) {
|
||||
return $this->service->getParameterSchema($modelId);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/calculate-preview",
|
||||
* summary="Calculate output values preview",
|
||||
* description="Calculate output parameter values based on input parameters using formulas",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"BOM Resolver"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="input_parameters",
|
||||
* description="Input parameter values",
|
||||
* type="object",
|
||||
* additionalProperties=@OA\Property(oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string"),
|
||||
* @OA\Schema(type="boolean")
|
||||
* }),
|
||||
* example={"W0": 1000, "H0": 800, "installation_type": "A"}
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Output values calculated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(
|
||||
* property="calculated_values",
|
||||
* type="object",
|
||||
* additionalProperties=@OA\Property(oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string")
|
||||
* }),
|
||||
* example={"W1": 1050, "H1": 850, "area": 892500, "weight": 45.5}
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="calculation_steps",
|
||||
* type="array",
|
||||
* @OA\Items(
|
||||
* @OA\Property(property="parameter", type="string", example="W1"),
|
||||
* @OA\Property(property="formula", type="string", example="W0 + 50"),
|
||||
* @OA\Property(property="result", oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string")
|
||||
* }, example=1050)
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function calculatePreview(int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId) {
|
||||
$inputParameters = request()->input('input_parameters', []);
|
||||
return $this->service->calculatePreview($modelId, $inputParameters);
|
||||
}, __('message.calculated'));
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Design;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ModelFormulaService;
|
||||
use App\Http\Requests\Api\V1\Design\ModelFormulaFormRequest;
|
||||
use App\Http\Requests\Api\V1\ModelFormula\IndexModelFormulaRequest;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="Model Formulas", description="Model formula management APIs")
|
||||
*/
|
||||
class ModelFormulaController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected ModelFormulaService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/design/models/{modelId}/formulas",
|
||||
* summary="Get model formulas",
|
||||
* description="Retrieve all formulas for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Formulas"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="page",
|
||||
* description="Page number for pagination",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="per_page",
|
||||
* description="Items per page",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=20)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="search",
|
||||
* description="Search by formula name or target parameter",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="string", example="calculate_area")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model formulas retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* @OA\Items(ref="#/components/schemas/ModelFormulaResource")
|
||||
* ),
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(property="last_page", type="integer", example=2),
|
||||
* @OA\Property(property="per_page", type="integer", example=20),
|
||||
* @OA\Property(property="total", type="integer", example=25)
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function index(IndexModelFormulaRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->getModelFormulas($modelId, $request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/formulas",
|
||||
* summary="Create model formula",
|
||||
* description="Create a new formula for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Formulas"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/CreateModelFormulaRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=201,
|
||||
* description="Model formula created successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ModelFormulaResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401)
|
||||
* )
|
||||
*/
|
||||
public function store(ModelFormulaFormRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->createFormula($modelId, $request->validated());
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* path="/v1/design/models/{modelId}/formulas/{formulaId}",
|
||||
* summary="Update model formula",
|
||||
* description="Update a specific model formula",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Formulas"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="formulaId",
|
||||
* description="Formula ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/UpdateModelFormulaRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model formula updated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ModelFormulaResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function update(ModelFormulaFormRequest $request, int $modelId, int $formulaId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId, $formulaId) {
|
||||
return $this->service->updateFormula($modelId, $formulaId, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/v1/design/models/{modelId}/formulas/{formulaId}",
|
||||
* summary="Delete model formula",
|
||||
* description="Delete a specific model formula",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Formulas"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="formulaId",
|
||||
* description="Formula ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model formula deleted successfully",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ApiResponse")
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function destroy(int $modelId, int $formulaId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId, $formulaId) {
|
||||
$this->service->deleteFormula($modelId, $formulaId);
|
||||
return null;
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/formulas/{formulaId}/validate",
|
||||
* summary="Validate model formula",
|
||||
* description="Validate formula expression and dependencies",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Formulas"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="formulaId",
|
||||
* description="Formula ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Formula validation result",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(property="is_valid", type="boolean", example=true),
|
||||
* @OA\Property(
|
||||
* property="validation_errors",
|
||||
* type="array",
|
||||
* @OA\Items(type="string", example="Unknown variable: unknown_var")
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="dependency_chain",
|
||||
* type="array",
|
||||
* @OA\Items(type="string", example="W0")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function validate(int $modelId, int $formulaId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId, $formulaId) {
|
||||
return $this->service->validateFormula($modelId, $formulaId);
|
||||
}, __('message.formula.validated'));
|
||||
}
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Design;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ModelParameterService;
|
||||
use App\Http\Requests\Api\V1\Design\ModelParameterFormRequest;
|
||||
use App\Http\Requests\Api\V1\ModelParameter\IndexModelParameterRequest;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="Model Parameters", description="Model parameter management APIs")
|
||||
*/
|
||||
class ModelParameterController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected ModelParameterService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/design/models/{modelId}/parameters",
|
||||
* summary="Get model parameters",
|
||||
* description="Retrieve all parameters for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Parameters"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="page",
|
||||
* description="Page number for pagination",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="per_page",
|
||||
* description="Items per page",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="integer", example=20)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="search",
|
||||
* description="Search by parameter name or label",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="string", example="width")
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="type",
|
||||
* description="Filter by parameter type",
|
||||
* in="query",
|
||||
* required=false,
|
||||
* @OA\Schema(type="string", enum={"INPUT", "OUTPUT"}, example="INPUT")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model parameters retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* type="array",
|
||||
* @OA\Items(ref="#/components/schemas/ModelParameterResource")
|
||||
* ),
|
||||
* @OA\Property(property="current_page", type="integer", example=1),
|
||||
* @OA\Property(property="last_page", type="integer", example=3),
|
||||
* @OA\Property(property="per_page", type="integer", example=20),
|
||||
* @OA\Property(property="total", type="integer", example=45)
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function index(IndexModelParameterRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->getModelParameters($modelId, $request->validated());
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/parameters",
|
||||
* summary="Create model parameter",
|
||||
* description="Create a new parameter for a specific model",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Parameters"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/CreateModelParameterRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=201,
|
||||
* description="Model parameter created successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ModelParameterResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401)
|
||||
* )
|
||||
*/
|
||||
public function store(ModelParameterFormRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
return $this->service->createParameter($modelId, $request->validated());
|
||||
}, __('message.created'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Put(
|
||||
* path="/v1/design/models/{modelId}/parameters/{parameterId}",
|
||||
* summary="Update model parameter",
|
||||
* description="Update a specific model parameter",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Parameters"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="parameterId",
|
||||
* description="Parameter ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/UpdateModelParameterRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model parameter updated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ModelParameterResource")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function update(ModelParameterFormRequest $request, int $modelId, int $parameterId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId, $parameterId) {
|
||||
return $this->service->updateParameter($modelId, $parameterId, $request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/v1/design/models/{modelId}/parameters/{parameterId}",
|
||||
* summary="Delete model parameter",
|
||||
* description="Delete a specific model parameter",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Model Parameters"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="parameterId",
|
||||
* description="Parameter ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Model parameter deleted successfully",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ApiResponse")
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function destroy(int $modelId, int $parameterId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($modelId, $parameterId) {
|
||||
$this->service->deleteParameter($modelId, $parameterId);
|
||||
return null;
|
||||
}, __('message.deleted'));
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1\Design;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ProductFromModelService;
|
||||
use App\Http\Requests\Api\V1\Design\ProductFromModelFormRequest;
|
||||
|
||||
/**
|
||||
* @OA\Tag(name="Product from Model", description="Product creation from model APIs")
|
||||
*/
|
||||
class ProductFromModelController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected ProductFromModelService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/design/models/{modelId}/create-product",
|
||||
* summary="Create product from model",
|
||||
* description="Create actual product with resolved BOM based on model and input parameters",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Product from Model"},
|
||||
* @OA\Parameter(
|
||||
* name="modelId",
|
||||
* description="Model ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(ref="#/components/schemas/CreateProductFromModelRequest")
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=201,
|
||||
* description="Product created successfully with resolved BOM",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductWithBomResponse")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function createProduct(ProductFromModelFormRequest $request, int $modelId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request, $modelId) {
|
||||
$data = $request->validated();
|
||||
$data['model_id'] = $modelId;
|
||||
return $this->service->createProductWithBom($data);
|
||||
}, __('message.product.created_from_model'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/products/{productId}/parameters",
|
||||
* summary="Get product parameters",
|
||||
* description="Retrieve parameters used to create this product",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Product from Model"},
|
||||
* @OA\Parameter(
|
||||
* name="productId",
|
||||
* description="Product ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Product parameters retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductParametersResponse")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function getProductParameters(int $productId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($productId) {
|
||||
return $this->service->getProductParameters($productId);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/products/{productId}/calculated-values",
|
||||
* summary="Get product calculated values",
|
||||
* description="Retrieve calculated output values for this product",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Product from Model"},
|
||||
* @OA\Parameter(
|
||||
* name="productId",
|
||||
* description="Product ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Product calculated values retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductCalculatedValuesResponse")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function getCalculatedValues(int $productId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($productId) {
|
||||
return $this->service->getCalculatedValues($productId);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/v1/products/{productId}/recalculate",
|
||||
* summary="Recalculate product values",
|
||||
* description="Recalculate product BOM and values with updated parameters",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Product from Model"},
|
||||
* @OA\Parameter(
|
||||
* name="productId",
|
||||
* description="Product ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\RequestBody(
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* @OA\Property(
|
||||
* property="input_parameters",
|
||||
* description="Updated input parameter values",
|
||||
* type="object",
|
||||
* additionalProperties=@OA\Property(oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string"),
|
||||
* @OA\Schema(type="boolean")
|
||||
* }),
|
||||
* example={"W0": 1200, "H0": 900, "installation_type": "B"}
|
||||
* ),
|
||||
* @OA\Property(
|
||||
* property="update_bom",
|
||||
* description="Whether to update the BOM components",
|
||||
* type="boolean",
|
||||
* example=true
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Product recalculated successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(property="data", ref="#/components/schemas/ProductWithBomResponse")
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function recalculate(int $productId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($productId) {
|
||||
$inputParameters = request()->input('input_parameters', []);
|
||||
$updateBom = request()->boolean('update_bom', true);
|
||||
|
||||
return $this->service->recalculateProduct($productId, $inputParameters, $updateBom);
|
||||
}, __('message.product.recalculated'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/v1/products/{productId}/model-info",
|
||||
* summary="Get product model information",
|
||||
* description="Retrieve the model information used to create this product",
|
||||
* security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}},
|
||||
* tags={"Product from Model"},
|
||||
* @OA\Parameter(
|
||||
* name="productId",
|
||||
* description="Product ID",
|
||||
* in="path",
|
||||
* required=true,
|
||||
* @OA\Schema(type="integer", example=1)
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Product model information retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* allOf={
|
||||
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
|
||||
* @OA\Schema(
|
||||
* @OA\Property(
|
||||
* property="data",
|
||||
* @OA\Property(property="model_id", type="integer", example=1),
|
||||
* @OA\Property(property="model_code", type="string", example="KSS01"),
|
||||
* @OA\Property(property="model_name", type="string", example="Standard Screen"),
|
||||
* @OA\Property(property="model_version", type="string", example="v1.0"),
|
||||
* @OA\Property(property="creation_timestamp", type="string", format="date-time"),
|
||||
* @OA\Property(
|
||||
* property="input_parameters_used",
|
||||
* type="object",
|
||||
* additionalProperties=@OA\Property(oneOf={
|
||||
* @OA\Schema(type="number"),
|
||||
* @OA\Schema(type="string"),
|
||||
* @OA\Schema(type="boolean")
|
||||
* }),
|
||||
* example={"W0": 1000, "H0": 800, "installation_type": "A"}
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(ref="#/components/responses/ErrorResponse", response=400),
|
||||
* @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401),
|
||||
* @OA\Response(ref="#/components/responses/NotFoundResponse", response=404)
|
||||
* )
|
||||
*/
|
||||
public function getModelInfo(int $productId)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($productId) {
|
||||
return $this->service->getProductModelInfo($productId);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user