feat: DB 연결 오버라이딩 및 대시보드 통계 위젯 추가
- DB 연결: 로컬/Docker 환경 오버라이딩 설정 (.env) - 테넌트 위젯: redirect 버그 수정 (TenantSelectorWidget) - 통계 위젯: 사용자/제품/자재/주문 카드 추가 (StatsOverviewWidget) - 리소스 한국어화: Product, Material 모델 레이블 추가 - 대시보드: 위젯 등록 및 캐시 최적화 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
281
app/Http/Controllers/Api/V1/Design/BomResolverController.php
Normal file
281
app/Http/Controllers/Api/V1/Design/BomResolverController.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user