From d3fb00ae264276a5dd2ffd25562db12b2fe256ef Mon Sep 17 00:00:00 2001 From: hskwon Date: Thu, 27 Nov 2025 22:01:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=84=B9=EC=85=98=20=EB=B3=B5=EC=A0=9C?= =?UTF-8?q?=20=EC=8B=9C=20=ED=95=84=EB=93=9C/BOM=20=EB=A7=81=ED=81=AC?= =?UTF-8?q?=EB=A7=8C=20=EC=83=9D=EC=84=B1=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 섹션 복제 시 필드를 새로 CREATE하던 로직 제거 - 섹션 복제 시 BOM을 새로 CREATE하던 로직 제거 - 기존 필드/BOM ID로 EntityRelationship 링크만 생성 - 독립 엔티티 아키텍처 원칙 준수 (복제 = 자신만 복제 + 관계 링크만 복제) - 불필요한 use 문 제거 (ItemField, ItemBomItem) --- .../ItemMaster/ItemSectionService.php | 42 ++----------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/app/Services/ItemMaster/ItemSectionService.php b/app/Services/ItemMaster/ItemSectionService.php index 4283a3d..b28f08f 100644 --- a/app/Services/ItemMaster/ItemSectionService.php +++ b/app/Services/ItemMaster/ItemSectionService.php @@ -3,8 +3,6 @@ namespace App\Services\ItemMaster; use App\Models\ItemMaster\EntityRelationship; -use App\Models\ItemMaster\ItemBomItem; -use App\Models\ItemMaster\ItemField; use App\Models\ItemMaster\ItemSection; use App\Services\Service; use App\Traits\LockCheckTrait; @@ -94,60 +92,28 @@ public function clone(int $id): ItemSection 'created_by' => $userId, ]); - // 필드 복제 (entity_relationships 기반) + // 기존 필드에 대한 링크만 생성 (필드는 복제하지 않음 - 링크 관계) foreach ($original->getRelation('fields') as $orderNo => $field) { - $clonedField = ItemField::create([ - 'tenant_id' => $tenantId, - 'group_id' => $field->group_id, - 'field_name' => $field->field_name, - 'field_type' => $field->field_type, - 'order_no' => $field->order_no, - 'is_required' => $field->is_required, - 'default_value' => $field->default_value, - 'placeholder' => $field->placeholder, - 'display_condition' => $field->display_condition, - 'validation_rules' => $field->validation_rules, - 'options' => $field->options, - 'properties' => $field->properties, - 'created_by' => $userId, - ]); - - // 섹션-필드 관계 생성 EntityRelationship::link( $tenantId, EntityRelationship::TYPE_SECTION, $cloned->id, EntityRelationship::TYPE_FIELD, - $clonedField->id, + $field->id, $field->order_no, null, $field->group_id ); } - // BOM 항목 복제 (entity_relationships 기반) + // 기존 BOM에 대한 링크만 생성 (BOM은 복제하지 않음 - 링크 관계) foreach ($original->getRelation('bomItems') as $orderNo => $bom) { - $clonedBom = ItemBomItem::create([ - 'tenant_id' => $tenantId, - 'group_id' => $bom->group_id, - 'item_code' => $bom->item_code, - 'item_name' => $bom->item_name, - 'quantity' => $bom->quantity, - 'unit' => $bom->unit, - 'unit_price' => $bom->unit_price, - 'total_price' => $bom->total_price, - 'spec' => $bom->spec, - 'note' => $bom->note, - 'created_by' => $userId, - ]); - - // 섹션-BOM 관계 생성 EntityRelationship::link( $tenantId, EntityRelationship::TYPE_SECTION, $cloned->id, EntityRelationship::TYPE_BOM, - $clonedBom->id, + $bom->id, $orderNo, null, $bom->group_id