From aee6d12fd9d75c5b4018dc23bd1796001058ad28 Mon Sep 17 00:00:00 2001 From: hskwon Date: Tue, 16 Dec 2025 10:08:07 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"docs:=20items=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=20=ED=86=B5=ED=95=A9=20=EC=99=84=EB=A3=8C=20=EB=82=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=98=EC=98=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e863d3762ab558375b220b09f99b701399d1f3f1. --- front/item-master-guide.md | 5 +- rules/item-policy.md | 112 ++++++++++++++++++------------------- specs/database-schema.md | 62 +++++--------------- 3 files changed, 71 insertions(+), 108 deletions(-) diff --git a/front/item-master-guide.md b/front/item-master-guide.md index 05b0fac..42c5def 100644 --- a/front/item-master-guide.md +++ b/front/item-master-guide.md @@ -174,15 +174,13 @@ interface ItemPage { group_id: number; page_name: string; item_type: 'FG' | 'PT' | 'SM' | 'RM' | 'CS'; - source_table: 'items'; // 통합됨 (2025-12-15) + source_table: 'products' | 'materials'; absolute_path?: string; is_active: boolean; sections: ItemSection[]; // init 응답에 포함 } ``` -> **통합 완료**: 기존 `products`/`materials` 분리 구조가 `items` 단일 테이블로 통합되었습니다. - ### 3.2 ItemSection ```typescript @@ -335,7 +333,6 @@ init API 응답에 `is_locked` 필드가 포함됩니다. | 날짜 | 변경 내용 | |------|----------| -| 2025-12-16 | items 테이블 통합 반영 (source_table: 'items') | | 2025-12-09 | 시스템 기반 문서 전면 재작성 | | 2025-11-27 | 잠금(Lock) 기능 추가 | | 2025-11-26 | 독립 엔티티 아키텍처 적용 | diff --git a/rules/item-policy.md b/rules/item-policy.md index d2431d4..161fe6b 100644 --- a/rules/item-policy.md +++ b/rules/item-policy.md @@ -2,7 +2,7 @@ > 품목 관리 시스템의 핵심 비즈니스 규칙 정의 > -> **최종 업데이트**: 2025-12-16 +> **최종 업데이트**: 2025-12-09 --- @@ -10,50 +10,41 @@ ### 1.1 품목 유형 코드 정의 -| 코드 | 한글명 | 영문명 | 설명 | -|------|--------|--------|------| -| `FG` | 완제품 | Finished Goods | 판매 가능한 최종 제품 | -| `PT` | 부품 | Parts | 제품 구성에 사용되는 부품 | -| `SM` | 부자재 | Sub-Materials | 생산에 사용되는 보조 자재 | -| `RM` | 원자재 | Raw Materials | 생산의 주요 원료 | -| `CS` | 소모품 | Consumables | 일회성 소모 자재 | - -> **통합 완료 (2025-12-15)**: 기존 products/materials 테이블이 **items 테이블로 통합**되었습니다. +| 코드 | 한글명 | 영문명 | source_table | 설명 | +|------|--------|--------|--------------|------| +| `FG` | 완제품 | Finished Goods | products | 판매 가능한 최종 제품 | +| `PT` | 부품 | Parts | products | 제품 구성에 사용되는 부품 | +| `SM` | 부자재 | Sub-Materials | materials | 생산에 사용되는 보조 자재 | +| `RM` | 원자재 | Raw Materials | materials | 생산의 주요 원료 | +| `CS` | 소모품 | Consumables | materials | 일회성 소모 자재 | ### 1.2 저장 위치 ``` -items 테이블 (통합) -├─ item_type = 'FG' | 'PT' | 'SM' | 'RM' | 'CS' -├─ code, name, unit, category_id -├─ bom (JSON) -└─ is_active +common_codes 테이블 +├─ code_group = 'item_type' +├─ code = 'FG' | 'PT' | 'SM' | 'RM' | 'CS' +└─ attributes.source_table = 'products' | 'materials' ``` -### 1.3 관련 테이블 구조 +### 1.3 source_table 매핑 규칙 ``` -items (통합 테이블) -├─ id, tenant_id, item_type -├─ code, name, unit, category_id -├─ bom (JSON) -├─ is_active -└─ timestamps + soft deletes +item_type → source_table 자동 매핑: -item_details (확장 필드 - 1:1) -├─ is_sellable, is_purchasable, is_producible -├─ safety_stock, lead_time -└─ is_inspection 등 +FG (완제품) ─┐ +PT (부품) ─┴─→ products 테이블 -item_attributes (동적 속성 - 1:1) -├─ attributes (JSON) -└─ options (JSON) +SM (부자재) ─┐ +RM (원자재) ─┼─→ materials 테이블 +CS (소모품) ─┘ ``` ### 1.4 테넌트별 확장 - 품목 유형은 테넌트별로 커스터마이징 가능 - `common_codes.attributes` JSON 필드 활용 (스키마 변경 없음) +- 새 품목 유형 추가 시 source_table 매핑 필수 --- @@ -64,43 +55,54 @@ item_attributes (동적 속성 - 1:1) | 용어 | 필드명 | 값 | 용도 | |------|--------|-----|------| | **품목 유형** | `item_type` | FG, PT, SM, RM, CS | API 파라미터, UI 필터링, 비즈니스 분류 | - -> ⚠️ **Deprecated**: `source_table`, `ref_type` 개념은 items 테이블 통합으로 더 이상 사용되지 않습니다. +| **저장 테이블** | `source_table` | products, materials | 내부 DB 분기, 서비스 로직 | +| **참조 타입** | `ref_type` | PRODUCT, MATERIAL | 폴리모픽 관계 (BOM, Prices 등) | ### 2.2 사용 규칙 - **API 레벨**: `item_type` 파라미터 사용 -- **서비스 레벨**: items 테이블 단일 조회 (item_type으로 필터링) +- **서비스 레벨**: `source_table`로 테이블 분기 +- **폴리모픽 관계**: `ref_type`으로 참조 (기존 호환성 유지) ### 2.3 API 흐름 예시 ``` 1. 클라이언트 요청: GET /api/v1/items?item_type=FG ↓ -2. 서버 처리: items 테이블에서 item_type='FG' 조회 +2. 서버 처리: item_type='FG' → common_codes 조회 ↓ -3. 응답 반환: item_type='FG' 포함하여 응답 +3. 테이블 분기: source_table='products' 확인 + ↓ +4. 데이터 조회: products 테이블에서 조회 + ↓ +5. 응답 반환: item_type='FG' 포함하여 응답 ``` --- ## 3. 필드 키 예약어 정책 -### 3.1 items 테이블 예약어 (통합) +### 3.1 products 테이블 예약어 ```php // 사용 불가 field_key 목록 -'code', 'name', 'unit', 'category_id', 'item_type', 'bom', 'is_active', -'attributes', 'options' +'code', 'name', 'unit', 'category_id', 'product_type', 'description', +'is_sellable', 'is_purchasable', 'is_producible', 'is_variable_size', 'is_active', +'safety_stock', 'lead_time', 'product_category', 'part_type', +'bending_diagram', 'bending_details', +'specification_file', 'specification_file_name', +'certification_file', 'certification_file_name', +'certification_number', 'certification_start_date', 'certification_end_date', +'attributes', 'attributes_archive' ``` -### 3.2 item_details 테이블 예약어 +### 3.2 materials 테이블 예약어 ```php -// 사용 불가 field_key 목록 (확장 필드) -'is_sellable', 'is_purchasable', 'is_producible', 'is_variable_size', -'safety_stock', 'lead_time', 'product_category', 'part_type', -'is_inspection' +// 사용 불가 field_key 목록 +'name', 'item_name', 'specification', 'material_code', 'material_type', +'unit', 'category_id', 'is_inspection', 'is_active', +'search_tag', 'remarks', 'attributes', 'options' ``` ### 3.3 공통 시스템 컬럼 (모든 테이블) @@ -118,7 +120,9 @@ item_attributes (동적 속성 - 1:1) ``` field_key 입력 ↓ - items 테이블 예약어 체크 + source_table 확인 (products / materials) + ↓ + 해당 테이블 예약어 체크 ↓ 기존 필드 중복 체크 ↓ @@ -266,24 +270,19 @@ item_attributes (동적 속성 - 1:1) ### 8.1 완료 항목 - ✅ item_type 코드 시딩 (ItemTypeSeeder) +- ✅ common_codes에 attributes.source_table 매핑 - ✅ field_key 예약어 검증 (SystemFields) - ✅ ItemMaster CRUD API (Pages, Sections, Fields) - ✅ 독립 엔티티 아키텍처 (entity_relationships) -- ✅ **items 테이블 통합** (2025-12-15) - - products/materials 테이블 삭제 - - items + item_details + item_attributes 구조 - - 전체 item_type (FG, PT, SM, RM, CS) 지원 -### 8.2 API 현황 (통합 완료) +### 8.2 개발 필요 항목 -| API | 상태 | 설명 | -|-----|:----:|------| -| `GET /api/v1/items` | ✅ | 전체 품목 조회 (item_type 필터) | -| `POST /api/v1/items` | ✅ | 품목 생성 | -| `GET /api/v1/items/{id}` | ✅ | 품목 상세 조회 | -| `PUT /api/v1/items/{id}` | ✅ | 품목 수정 | -| `DELETE /api/v1/items/{id}` | ✅ | 품목 삭제 | -| `DELETE /api/v1/items/batch` | ✅ | 품목 일괄 삭제 | +| API | Product | Material | 작업 내용 | +|-----|:-------:|:--------:|----------| +| `PUT /items/{id}` | ✅ | ❌ | Material 수정 지원 추가 | +| `DELETE /items/{id}` | ✅ | ❌ | Material 삭제 지원 추가 | +| `DELETE /items/batch` | ✅ | ❌ | Material 일괄삭제 지원 | +| `GET /items/code/{code}` | ✅ | ❌ | Material 코드 조회 지원 | --- @@ -291,5 +290,4 @@ item_attributes (동적 속성 - 1:1) | 날짜 | 내용 | |------|------| -| 2025-12-16 | items 테이블 통합 완료 반영 (products/materials → items) | | 2025-12-09 | 문서 생성 - 4개 문서 통합 (items-api-unified-plan, field-integration, field-key-validation, INDEX) | \ No newline at end of file diff --git a/specs/database-schema.md b/specs/database-schema.md index 5f5b238..ecc7cb2 100644 --- a/specs/database-schema.md +++ b/specs/database-schema.md @@ -1,6 +1,6 @@ # SAM 데이터베이스 스키마 -**업데이트**: 2025-12-16 +**업데이트**: 2025-11-24 **데이터베이스**: samdb (MySQL 8.0.43) **전체 테이블**: 92개 @@ -176,23 +176,21 @@ #### category_templates - 버전 관리된 카테고리 필드 스냅샷 -#### items (통합 - 2025-12-15) -- **품목 통합 테이블** (기존 products/materials 통합) -- 타입 분류: `FG` (완제품), `PT` (부품), `SM` (부자재), `RM` (원자재), `CS` (소모품) -- 주요 컬럼: `item_type`, `code`, `name`, `unit`, `category_id`, `bom` (JSON) -- 1:1 확장 테이블: `item_details`, `item_attributes` +#### products +- 제품 카탈로그 +- 타입 분류: `PRODUCT`, `PART`, `SUBASSEMBLY` -#### item_details -- items 확장 필드 (1:1 관계) -- `is_sellable`, `is_purchasable`, `is_producible`, `safety_stock`, `lead_time` 등 +#### product_components +- BOM 관계 +- `MATERIAL` 또는 `PRODUCT` 참조 -#### item_attributes -- 동적 속성 저장 (1:1 관계) -- `attributes` (JSON), `options` (JSON) +#### materials +- 자재 마스터 +- 동적 속성 지원 #### classifications - 그룹별 플랫 코드 테이블 -- 예: `item_type`, `payment_method` +- 예: `product_type`, `payment_method` ### 디자인 및 제조 @@ -319,10 +317,9 @@ ``` Tenant → Users (many-to-many via user_tenants) -Items → ItemDetails, ItemAttributes (1:1 확장) -Items.bom (JSON) → 자체 참조 BOM 구조 +Products ↔ Materials (via product_components with ref_type) Models → Versions → BOM Templates (design workflow) -Orders → OrderItems → Items (주문 구조) +Orders → Items → Components (order breakdown) Categories ↔ Fields ↔ Templates (dynamic forms with versioning) Audit Logs (polymorphic tracking across all major entities) ``` @@ -473,34 +470,5 @@ $role->syncPermissions(['users.view', 'users.create']); --- -## Items 테이블 통합 (2025-12-15) - -### 완료 항목 -- ✅ products/materials 테이블 → items 테이블로 통합 -- ✅ item_details (확장 필드), item_attributes (동적 속성) 분리 -- ✅ BOM 구조 단순화 (child_item_id만 사용) -- ✅ 기존 Product, Material 모델/서비스 삭제 - -### 테이블 구조 -```sql -items ( - id, tenant_id, item_type, code, name, unit, - category_id, bom JSON, is_active, - created_by, updated_by, deleted_by, timestamps, soft_delete -) - -item_details ( - id, item_id, is_sellable, is_purchasable, is_producible, - safety_stock, lead_time, is_inspection, ... -) - -item_attributes ( - id, item_id, attributes JSON, options JSON -) -``` - ---- - -**최종 업데이트**: 2025-12-16 -**Phase 4**: 완료 (8개 테이블 상세화) -**Items 통합**: 완료 (2025-12-15) \ No newline at end of file +**최종 업데이트**: 2025-11-24 +**Phase 4**: 완료 (8개 테이블 상세화) \ No newline at end of file