@@ -174,15 +174,13 @@ interface ItemPage {
|
|||||||
group_id: number;
|
group_id: number;
|
||||||
page_name: string;
|
page_name: string;
|
||||||
item_type: 'FG' | 'PT' | 'SM' | 'RM' | 'CS';
|
item_type: 'FG' | 'PT' | 'SM' | 'RM' | 'CS';
|
||||||
source_table: 'items'; // 통합됨 (2025-12-15)
|
source_table: 'products' | 'materials';
|
||||||
absolute_path?: string;
|
absolute_path?: string;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
sections: ItemSection[]; // init 응답에 포함
|
sections: ItemSection[]; // init 응답에 포함
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> **통합 완료**: 기존 `products`/`materials` 분리 구조가 `items` 단일 테이블로 통합되었습니다.
|
|
||||||
|
|
||||||
### 3.2 ItemSection
|
### 3.2 ItemSection
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@@ -335,7 +333,6 @@ init API 응답에 `is_locked` 필드가 포함됩니다.
|
|||||||
|
|
||||||
| 날짜 | 변경 내용 |
|
| 날짜 | 변경 내용 |
|
||||||
|------|----------|
|
|------|----------|
|
||||||
| 2025-12-16 | items 테이블 통합 반영 (source_table: 'items') |
|
|
||||||
| 2025-12-09 | 시스템 기반 문서 전면 재작성 |
|
| 2025-12-09 | 시스템 기반 문서 전면 재작성 |
|
||||||
| 2025-11-27 | 잠금(Lock) 기능 추가 |
|
| 2025-11-27 | 잠금(Lock) 기능 추가 |
|
||||||
| 2025-11-26 | 독립 엔티티 아키텍처 적용 |
|
| 2025-11-26 | 독립 엔티티 아키텍처 적용 |
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
> 품목 관리 시스템의 핵심 비즈니스 규칙 정의
|
> 품목 관리 시스템의 핵심 비즈니스 규칙 정의
|
||||||
>
|
>
|
||||||
> **최종 업데이트**: 2025-12-16
|
> **최종 업데이트**: 2025-12-09
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -10,50 +10,41 @@
|
|||||||
|
|
||||||
### 1.1 품목 유형 코드 정의
|
### 1.1 품목 유형 코드 정의
|
||||||
|
|
||||||
| 코드 | 한글명 | 영문명 | 설명 |
|
| 코드 | 한글명 | 영문명 | source_table | 설명 |
|
||||||
|------|--------|--------|------|
|
|------|--------|--------|--------------|------|
|
||||||
| `FG` | 완제품 | Finished Goods | 판매 가능한 최종 제품 |
|
| `FG` | 완제품 | Finished Goods | products | 판매 가능한 최종 제품 |
|
||||||
| `PT` | 부품 | Parts | 제품 구성에 사용되는 부품 |
|
| `PT` | 부품 | Parts | products | 제품 구성에 사용되는 부품 |
|
||||||
| `SM` | 부자재 | Sub-Materials | 생산에 사용되는 보조 자재 |
|
| `SM` | 부자재 | Sub-Materials | materials | 생산에 사용되는 보조 자재 |
|
||||||
| `RM` | 원자재 | Raw Materials | 생산의 주요 원료 |
|
| `RM` | 원자재 | Raw Materials | materials | 생산의 주요 원료 |
|
||||||
| `CS` | 소모품 | Consumables | 일회성 소모 자재 |
|
| `CS` | 소모품 | Consumables | materials | 일회성 소모 자재 |
|
||||||
|
|
||||||
> **통합 완료 (2025-12-15)**: 기존 products/materials 테이블이 **items 테이블로 통합**되었습니다.
|
|
||||||
|
|
||||||
### 1.2 저장 위치
|
### 1.2 저장 위치
|
||||||
|
|
||||||
```
|
```
|
||||||
items 테이블 (통합)
|
common_codes 테이블
|
||||||
├─ item_type = 'FG' | 'PT' | 'SM' | 'RM' | 'CS'
|
├─ code_group = 'item_type'
|
||||||
├─ code, name, unit, category_id
|
├─ code = 'FG' | 'PT' | 'SM' | 'RM' | 'CS'
|
||||||
├─ bom (JSON)
|
└─ attributes.source_table = 'products' | 'materials'
|
||||||
└─ is_active
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1.3 관련 테이블 구조
|
### 1.3 source_table 매핑 규칙
|
||||||
|
|
||||||
```
|
```
|
||||||
items (통합 테이블)
|
item_type → source_table 자동 매핑:
|
||||||
├─ id, tenant_id, item_type
|
|
||||||
├─ code, name, unit, category_id
|
|
||||||
├─ bom (JSON)
|
|
||||||
├─ is_active
|
|
||||||
└─ timestamps + soft deletes
|
|
||||||
|
|
||||||
item_details (확장 필드 - 1:1)
|
FG (완제품) ─┐
|
||||||
├─ is_sellable, is_purchasable, is_producible
|
PT (부품) ─┴─→ products 테이블
|
||||||
├─ safety_stock, lead_time
|
|
||||||
└─ is_inspection 등
|
|
||||||
|
|
||||||
item_attributes (동적 속성 - 1:1)
|
SM (부자재) ─┐
|
||||||
├─ attributes (JSON)
|
RM (원자재) ─┼─→ materials 테이블
|
||||||
└─ options (JSON)
|
CS (소모품) ─┘
|
||||||
```
|
```
|
||||||
|
|
||||||
### 1.4 테넌트별 확장
|
### 1.4 테넌트별 확장
|
||||||
|
|
||||||
- 품목 유형은 테넌트별로 커스터마이징 가능
|
- 품목 유형은 테넌트별로 커스터마이징 가능
|
||||||
- `common_codes.attributes` JSON 필드 활용 (스키마 변경 없음)
|
- `common_codes.attributes` JSON 필드 활용 (스키마 변경 없음)
|
||||||
|
- 새 품목 유형 추가 시 source_table 매핑 필수
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -64,43 +55,54 @@ item_attributes (동적 속성 - 1:1)
|
|||||||
| 용어 | 필드명 | 값 | 용도 |
|
| 용어 | 필드명 | 값 | 용도 |
|
||||||
|------|--------|-----|------|
|
|------|--------|-----|------|
|
||||||
| **품목 유형** | `item_type` | FG, PT, SM, RM, CS | API 파라미터, UI 필터링, 비즈니스 분류 |
|
| **품목 유형** | `item_type` | FG, PT, SM, RM, CS | API 파라미터, UI 필터링, 비즈니스 분류 |
|
||||||
|
| **저장 테이블** | `source_table` | products, materials | 내부 DB 분기, 서비스 로직 |
|
||||||
> ⚠️ **Deprecated**: `source_table`, `ref_type` 개념은 items 테이블 통합으로 더 이상 사용되지 않습니다.
|
| **참조 타입** | `ref_type` | PRODUCT, MATERIAL | 폴리모픽 관계 (BOM, Prices 등) |
|
||||||
|
|
||||||
### 2.2 사용 규칙
|
### 2.2 사용 규칙
|
||||||
|
|
||||||
- **API 레벨**: `item_type` 파라미터 사용
|
- **API 레벨**: `item_type` 파라미터 사용
|
||||||
- **서비스 레벨**: items 테이블 단일 조회 (item_type으로 필터링)
|
- **서비스 레벨**: `source_table`로 테이블 분기
|
||||||
|
- **폴리모픽 관계**: `ref_type`으로 참조 (기존 호환성 유지)
|
||||||
|
|
||||||
### 2.3 API 흐름 예시
|
### 2.3 API 흐름 예시
|
||||||
|
|
||||||
```
|
```
|
||||||
1. 클라이언트 요청: GET /api/v1/items?item_type=FG
|
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. 필드 키 예약어 정책
|
||||||
|
|
||||||
### 3.1 items 테이블 예약어 (통합)
|
### 3.1 products 테이블 예약어
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// 사용 불가 field_key 목록
|
// 사용 불가 field_key 목록
|
||||||
'code', 'name', 'unit', 'category_id', 'item_type', 'bom', 'is_active',
|
'code', 'name', 'unit', 'category_id', 'product_type', 'description',
|
||||||
'attributes', 'options'
|
'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
|
```php
|
||||||
// 사용 불가 field_key 목록 (확장 필드)
|
// 사용 불가 field_key 목록
|
||||||
'is_sellable', 'is_purchasable', 'is_producible', 'is_variable_size',
|
'name', 'item_name', 'specification', 'material_code', 'material_type',
|
||||||
'safety_stock', 'lead_time', 'product_category', 'part_type',
|
'unit', 'category_id', 'is_inspection', 'is_active',
|
||||||
'is_inspection'
|
'search_tag', 'remarks', 'attributes', 'options'
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3.3 공통 시스템 컬럼 (모든 테이블)
|
### 3.3 공통 시스템 컬럼 (모든 테이블)
|
||||||
@@ -118,7 +120,9 @@ item_attributes (동적 속성 - 1:1)
|
|||||||
```
|
```
|
||||||
field_key 입력
|
field_key 입력
|
||||||
↓
|
↓
|
||||||
items 테이블 예약어 체크
|
source_table 확인 (products / materials)
|
||||||
|
↓
|
||||||
|
해당 테이블 예약어 체크
|
||||||
↓
|
↓
|
||||||
기존 필드 중복 체크
|
기존 필드 중복 체크
|
||||||
↓
|
↓
|
||||||
@@ -266,24 +270,19 @@ item_attributes (동적 속성 - 1:1)
|
|||||||
### 8.1 완료 항목
|
### 8.1 완료 항목
|
||||||
|
|
||||||
- ✅ item_type 코드 시딩 (ItemTypeSeeder)
|
- ✅ item_type 코드 시딩 (ItemTypeSeeder)
|
||||||
|
- ✅ common_codes에 attributes.source_table 매핑
|
||||||
- ✅ field_key 예약어 검증 (SystemFields)
|
- ✅ field_key 예약어 검증 (SystemFields)
|
||||||
- ✅ ItemMaster CRUD API (Pages, Sections, Fields)
|
- ✅ ItemMaster CRUD API (Pages, Sections, Fields)
|
||||||
- ✅ 독립 엔티티 아키텍처 (entity_relationships)
|
- ✅ 독립 엔티티 아키텍처 (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 | 상태 | 설명 |
|
| API | Product | Material | 작업 내용 |
|
||||||
|-----|:----:|------|
|
|-----|:-------:|:--------:|----------|
|
||||||
| `GET /api/v1/items` | ✅ | 전체 품목 조회 (item_type 필터) |
|
| `PUT /items/{id}` | ✅ | ❌ | Material 수정 지원 추가 |
|
||||||
| `POST /api/v1/items` | ✅ | 품목 생성 |
|
| `DELETE /items/{id}` | ✅ | ❌ | Material 삭제 지원 추가 |
|
||||||
| `GET /api/v1/items/{id}` | ✅ | 품목 상세 조회 |
|
| `DELETE /items/batch` | ✅ | ❌ | Material 일괄삭제 지원 |
|
||||||
| `PUT /api/v1/items/{id}` | ✅ | 품목 수정 |
|
| `GET /items/code/{code}` | ✅ | ❌ | Material 코드 조회 지원 |
|
||||||
| `DELETE /api/v1/items/{id}` | ✅ | 품목 삭제 |
|
|
||||||
| `DELETE /api/v1/items/batch` | ✅ | 품목 일괄 삭제 |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -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) |
|
| 2025-12-09 | 문서 생성 - 4개 문서 통합 (items-api-unified-plan, field-integration, field-key-validation, INDEX) |
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# SAM 데이터베이스 스키마
|
# SAM 데이터베이스 스키마
|
||||||
|
|
||||||
**업데이트**: 2025-12-16
|
**업데이트**: 2025-11-24
|
||||||
**데이터베이스**: samdb (MySQL 8.0.43)
|
**데이터베이스**: samdb (MySQL 8.0.43)
|
||||||
**전체 테이블**: 92개
|
**전체 테이블**: 92개
|
||||||
|
|
||||||
@@ -176,23 +176,21 @@
|
|||||||
#### category_templates
|
#### category_templates
|
||||||
- 버전 관리된 카테고리 필드 스냅샷
|
- 버전 관리된 카테고리 필드 스냅샷
|
||||||
|
|
||||||
#### items (통합 - 2025-12-15)
|
#### products
|
||||||
- **품목 통합 테이블** (기존 products/materials 통합)
|
- 제품 카탈로그
|
||||||
- 타입 분류: `FG` (완제품), `PT` (부품), `SM` (부자재), `RM` (원자재), `CS` (소모품)
|
- 타입 분류: `PRODUCT`, `PART`, `SUBASSEMBLY`
|
||||||
- 주요 컬럼: `item_type`, `code`, `name`, `unit`, `category_id`, `bom` (JSON)
|
|
||||||
- 1:1 확장 테이블: `item_details`, `item_attributes`
|
|
||||||
|
|
||||||
#### item_details
|
#### product_components
|
||||||
- items 확장 필드 (1:1 관계)
|
- BOM 관계
|
||||||
- `is_sellable`, `is_purchasable`, `is_producible`, `safety_stock`, `lead_time` 등
|
- `MATERIAL` 또는 `PRODUCT` 참조
|
||||||
|
|
||||||
#### item_attributes
|
#### materials
|
||||||
- 동적 속성 저장 (1:1 관계)
|
- 자재 마스터
|
||||||
- `attributes` (JSON), `options` (JSON)
|
- 동적 속성 지원
|
||||||
|
|
||||||
#### classifications
|
#### classifications
|
||||||
- 그룹별 플랫 코드 테이블
|
- 그룹별 플랫 코드 테이블
|
||||||
- 예: `item_type`, `payment_method`
|
- 예: `product_type`, `payment_method`
|
||||||
|
|
||||||
### 디자인 및 제조
|
### 디자인 및 제조
|
||||||
|
|
||||||
@@ -319,10 +317,9 @@
|
|||||||
|
|
||||||
```
|
```
|
||||||
Tenant → Users (many-to-many via user_tenants)
|
Tenant → Users (many-to-many via user_tenants)
|
||||||
Items → ItemDetails, ItemAttributes (1:1 확장)
|
Products ↔ Materials (via product_components with ref_type)
|
||||||
Items.bom (JSON) → 자체 참조 BOM 구조
|
|
||||||
Models → Versions → BOM Templates (design workflow)
|
Models → Versions → BOM Templates (design workflow)
|
||||||
Orders → OrderItems → Items (주문 구조)
|
Orders → Items → Components (order breakdown)
|
||||||
Categories ↔ Fields ↔ Templates (dynamic forms with versioning)
|
Categories ↔ Fields ↔ Templates (dynamic forms with versioning)
|
||||||
Audit Logs (polymorphic tracking across all major entities)
|
Audit Logs (polymorphic tracking across all major entities)
|
||||||
```
|
```
|
||||||
@@ -473,34 +470,5 @@ $role->syncPermissions(['users.view', 'users.create']);
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Items 테이블 통합 (2025-12-15)
|
**최종 업데이트**: 2025-11-24
|
||||||
|
**Phase 4**: 완료 (8개 테이블 상세화)
|
||||||
### 완료 항목
|
|
||||||
- ✅ 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)
|
|
||||||
Reference in New Issue
Block a user