docs: items 테이블 통합 완료 내용 반영

- rules/item-policy.md: source_table 개념 제거, API 완료 상태 업데이트
- front/item-master-guide.md: source_table: 'items' 반영
- specs/database-schema.md: items 통합 테이블 구조 추가
This commit is contained in:
2025-12-16 10:01:30 +09:00
parent 3d6d7b67ea
commit e863d3762a
3 changed files with 108 additions and 71 deletions

View File

@@ -2,7 +2,7 @@
> 품목 관리 시스템의 핵심 비즈니스 규칙 정의
>
> **최종 업데이트**: 2025-12-09
> **최종 업데이트**: 2025-12-16
---
@@ -10,41 +10,50 @@
### 1.1 품목 유형 코드 정의
| 코드 | 한글명 | 영문명 | source_table | 설명 |
|------|--------|--------|--------------|------|
| `FG` | 완제품 | Finished Goods | products | 판매 가능한 최종 제품 |
| `PT` | 부품 | Parts | products | 제품 구성에 사용되는 부품 |
| `SM` | 부자재 | Sub-Materials | materials | 생산에 사용되는 보조 자재 |
| `RM` | 원자재 | Raw Materials | materials | 생산의 주요 원료 |
| `CS` | 소모품 | Consumables | materials | 일회성 소모 자재 |
| 코드 | 한글명 | 영문명 | 설명 |
|------|--------|--------|------|
| `FG` | 완제품 | Finished Goods | 판매 가능한 최종 제품 |
| `PT` | 부품 | Parts | 제품 구성에 사용되는 부품 |
| `SM` | 부자재 | Sub-Materials | 생산에 사용되는 보조 자재 |
| `RM` | 원자재 | Raw Materials | 생산의 주요 원료 |
| `CS` | 소모품 | Consumables | 일회성 소모 자재 |
> **통합 완료 (2025-12-15)**: 기존 products/materials 테이블이 **items 테이블로 통합**되었습니다.
### 1.2 저장 위치
```
common_codes 테이블
├─ code_group = 'item_type'
├─ code = 'FG' | 'PT' | 'SM' | 'RM' | 'CS'
attributes.source_table = 'products' | 'materials'
items 테이블 (통합)
├─ item_type = 'FG' | 'PT' | 'SM' | 'RM' | 'CS'
├─ code, name, unit, category_id
bom (JSON)
└─ is_active
```
### 1.3 source_table 매핑 규칙
### 1.3 관련 테이블 구조
```
item_type → source_table 자동 매핑:
items (통합 테이블)
├─ id, tenant_id, item_type
├─ code, name, unit, category_id
├─ bom (JSON)
├─ is_active
└─ timestamps + soft deletes
FG (완제품) ─┐
PT (부품) ─┴─→ products 테이블
item_details (확장 필드 - 1:1)
├─ is_sellable, is_purchasable, is_producible
├─ safety_stock, lead_time
└─ is_inspection 등
SM (부자재) ─┐
RM (원자재) ─┼─→ materials 테이블
CS (소모품) ─┘
item_attributes (동적 속성 - 1:1)
├─ attributes (JSON)
└─ options (JSON)
```
### 1.4 테넌트별 확장
- 품목 유형은 테넌트별로 커스터마이징 가능
- `common_codes.attributes` JSON 필드 활용 (스키마 변경 없음)
- 새 품목 유형 추가 시 source_table 매핑 필수
---
@@ -55,54 +64,43 @@ CS (소모품) ─┘
| 용어 | 필드명 | 값 | 용도 |
|------|--------|-----|------|
| **품목 유형** | `item_type` | FG, PT, SM, RM, CS | API 파라미터, UI 필터링, 비즈니스 분류 |
| **저장 테이블** | `source_table` | products, materials | 내부 DB 분기, 서비스 로직 |
| **참조 타입** | `ref_type` | PRODUCT, MATERIAL | 폴리모픽 관계 (BOM, Prices 등) |
> ⚠️ **Deprecated**: `source_table`, `ref_type` 개념은 items 테이블 통합으로 더 이상 사용되지 않습니다.
### 2.2 사용 규칙
- **API 레벨**: `item_type` 파라미터 사용
- **서비스 레벨**: `source_table`로 테이블 분기
- **폴리모픽 관계**: `ref_type`으로 참조 (기존 호환성 유지)
- **서비스 레벨**: items 테이블 단일 조회 (item_type으로 필터링)
### 2.3 API 흐름 예시
```
1. 클라이언트 요청: GET /api/v1/items?item_type=FG
2. 서버 처리: item_type='FG' → common_codes 조회
2. 서버 처리: items 테이블에서 item_type='FG' 조회
3. 테이블 분기: source_table='products' 확인
4. 데이터 조회: products 테이블에서 조회
5. 응답 반환: item_type='FG' 포함하여 응답
3. 응답 반환: item_type='FG' 포함하여 응답
```
---
## 3. 필드 키 예약어 정책
### 3.1 products 테이블 예약어
### 3.1 items 테이블 예약어 (통합)
```php
// 사용 불가 field_key 목록
'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'
'code', 'name', 'unit', 'category_id', 'item_type', 'bom', 'is_active',
'attributes', 'options'
```
### 3.2 materials 테이블 예약어
### 3.2 item_details 테이블 예약어
```php
// 사용 불가 field_key 목록
'name', 'item_name', 'specification', 'material_code', 'material_type',
'unit', 'category_id', 'is_inspection', 'is_active',
'search_tag', 'remarks', 'attributes', 'options'
// 사용 불가 field_key 목록 (확장 필드)
'is_sellable', 'is_purchasable', 'is_producible', 'is_variable_size',
'safety_stock', 'lead_time', 'product_category', 'part_type',
'is_inspection'
```
### 3.3 공통 시스템 컬럼 (모든 테이블)
@@ -120,9 +118,7 @@ CS (소모품) ─┘
```
field_key 입력
source_table 확인 (products / materials)
해당 테이블 예약어 체크
items 테이블 예약어 체크
기존 필드 중복 체크
@@ -270,19 +266,24 @@ CS (소모품) ─┘
### 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 개발 필요 항목
### 8.2 API 현황 (통합 완료)
| API | Product | Material | 작업 내용 |
|-----|:-------:|:--------:|----------|
| `PUT /items/{id}` | ✅ | ❌ | Material 수정 지원 추가 |
| `DELETE /items/{id}` | ✅ | ❌ | Material 삭제 지원 추가 |
| `DELETE /items/batch` | ✅ | ❌ | Material 일괄삭제 지원 |
| `GET /items/code/{code}` | ✅ | ❌ | Material 코드 조회 지원 |
| 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` | ✅ | 품목 일괄 삭제 |
---
@@ -290,4 +291,5 @@ CS (소모품) ─┘
| 날짜 | 내용 |
|------|------|
| 2025-12-16 | items 테이블 통합 완료 반영 (products/materials → items) |
| 2025-12-09 | 문서 생성 - 4개 문서 통합 (items-api-unified-plan, field-integration, field-key-validation, INDEX) |