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:
@@ -0,0 +1,335 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user