docs: 품목 정책 통합 문서 생성 및 중복 문서 정리
- rules/item-policy.md 생성 (4개 문서 통합) - 품목 유형 체계 (FG/PT/SM/RM/CS) - 필드 키 예약어 정책 - API 파라미터 규칙 - 구현 현황 정리 - 삭제된 문서: - plans/items-api-unified-plan.md - specs/ITEM-MASTER-INDEX.md - specs/item-master-field-integration.md - specs/item-master-field-key-validation.md - 업데이트: - INDEX.md: 품목관리 필수 문서 변경 - rules/README.md: item-policy.md 추가
This commit is contained in:
11
INDEX.md
11
INDEX.md
@@ -15,7 +15,7 @@
|
|||||||
| **Git 커밋** | `standards/git-conventions.md` | 커밋 메시지, 브랜치 전략 |
|
| **Git 커밋** | `standards/git-conventions.md` | 커밋 메시지, 브랜치 전략 |
|
||||||
| **품질 검증** | `standards/quality-checklist.md` | 코드 품질 체크리스트 |
|
| **품질 검증** | `standards/quality-checklist.md` | 코드 품질 체크리스트 |
|
||||||
| **Swagger 작성** | `guides/swagger-guide.md` | API 문서 작성 방법 |
|
| **Swagger 작성** | `guides/swagger-guide.md` | API 문서 작성 방법 |
|
||||||
| **품목관리** | `specs/item-master-integration.md` | 품목 시스템 스펙 |
|
| **품목관리** | `rules/item-policy.md` | 품목 정책 (유형, 예약어, API 규칙) |
|
||||||
| **게시판** | `specs/board-system-spec.md` | 게시판 시스템 설계 |
|
| **게시판** | `specs/board-system-spec.md` | 게시판 시스템 설계 |
|
||||||
| **단가관리** | `rules/pricing-policy.md` | 원가/판매가 계산, 리비전 관리 |
|
| **단가관리** | `rules/pricing-policy.md` | 원가/판매가 계산, 리비전 관리 |
|
||||||
| **MES 개발** | `projects/mes/README.md` | MES 프로젝트 개요 |
|
| **MES 개발** | `projects/mes/README.md` | MES 프로젝트 개요 |
|
||||||
@@ -68,6 +68,7 @@ docs/
|
|||||||
| 문서 | 설명 | 필수 확인 시점 |
|
| 문서 | 설명 | 필수 확인 시점 |
|
||||||
|------|------|--------------|
|
|------|------|--------------|
|
||||||
| [README.md](rules/README.md) | 비즈니스 규칙 개요 | 도메인 로직 구현 전 |
|
| [README.md](rules/README.md) | 비즈니스 규칙 개요 | 도메인 로직 구현 전 |
|
||||||
|
| [item-policy.md](rules/item-policy.md) | 품목 정책 (유형 체계, 예약어, API 규칙) | 품목 관련 작업 전 |
|
||||||
| [pricing-policy.md](rules/pricing-policy.md) | 단가 정책 (원가/판매가 계산, 리비전 관리) | 단가 관련 작업 전 |
|
| [pricing-policy.md](rules/pricing-policy.md) | 단가 정책 (원가/판매가 계산, 리비전 관리) | 단가 관련 작업 전 |
|
||||||
|
|
||||||
### specs/ - 기술 스펙
|
### specs/ - 기술 스펙
|
||||||
@@ -77,10 +78,7 @@ docs/
|
|||||||
|------|------|--------------|
|
|------|------|--------------|
|
||||||
| [database-schema.md](specs/database-schema.md) | DB 구조 및 관계도 | DB 변경 전 |
|
| [database-schema.md](specs/database-schema.md) | DB 구조 및 관계도 | DB 변경 전 |
|
||||||
| [board-system-spec.md](specs/board-system-spec.md) | 게시판 시스템 설계 | 게시판 작업 전 |
|
| [board-system-spec.md](specs/board-system-spec.md) | 게시판 시스템 설계 | 게시판 작업 전 |
|
||||||
| [**ITEM-MASTER-INDEX.md**](specs/ITEM-MASTER-INDEX.md) | **품목관리 문서 인덱스 (개발 현황)** | **품목 작업 전 필수** |
|
|
||||||
| [item-master-integration.md](specs/item-master-integration.md) | 품목관리 연동 설계 | 품목 연동 구현 시 |
|
| [item-master-integration.md](specs/item-master-integration.md) | 품목관리 연동 설계 | 품목 연동 구현 시 |
|
||||||
| [item-master-field-key-validation.md](specs/item-master-field-key-validation.md) | ItemMaster 필드 키 검증 | 품목 필드 작업 전 |
|
|
||||||
| [item-master-field-integration.md](specs/item-master-field-integration.md) | ItemMaster 필드 통합 계획 | 품목 필드 통합 시 |
|
|
||||||
| [docker-setup.md](specs/docker-setup.md) | Docker 환경 구성 | 환경 설정 시 |
|
| [docker-setup.md](specs/docker-setup.md) | Docker 환경 구성 | 환경 설정 시 |
|
||||||
| [remote-work-setup.md](specs/remote-work-setup.md) | 원격 개발 설정 | 원격 작업 시 |
|
| [remote-work-setup.md](specs/remote-work-setup.md) | 원격 개발 설정 | 원격 작업 시 |
|
||||||
|
|
||||||
@@ -189,6 +187,11 @@ API Flow Tester에서 생성되는 JSON 파일 저장 경로
|
|||||||
|
|
||||||
## 🔄 문서 구조 변경 이력
|
## 🔄 문서 구조 변경 이력
|
||||||
|
|
||||||
|
- **2025-12-09**: 품목 정책 통합 문서 생성
|
||||||
|
- `rules/item-policy.md` 생성 (4개 문서 통합)
|
||||||
|
- 삭제: `specs/ITEM-MASTER-INDEX.md`, `specs/item-master-field-key-validation.md`, `specs/item-master-field-integration.md`, `plans/items-api-unified-plan.md`
|
||||||
|
- 품목 관련 정책을 rules/ 디렉토리로 이동
|
||||||
|
|
||||||
- **2025-12-09**: Item Master 문서 정리 및 인덱스 생성
|
- **2025-12-09**: Item Master 문서 정리 및 인덱스 생성
|
||||||
- `specs/ITEM-MASTER-INDEX.md` 생성 (개발 현황/필요 항목 정리)
|
- `specs/ITEM-MASTER-INDEX.md` 생성 (개발 현황/필요 항목 정리)
|
||||||
- `history/2025-11/item-master-archived/` 생성 (구버전 문서 아카이브)
|
- `history/2025-11/item-master-archived/` 생성 (구버전 문서 아카이브)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
| 문서 | 설명 |
|
| 문서 | 설명 |
|
||||||
|------|------|
|
|------|------|
|
||||||
|
| [item-policy.md](item-policy.md) | 품목 정책 (유형 체계, 예약어, API 규칙) |
|
||||||
| [pricing-policy.md](pricing-policy.md) | 단가 정책 (원가/판매가 계산, 리비전 관리) |
|
| [pricing-policy.md](pricing-policy.md) | 단가 정책 (원가/판매가 계산, 리비전 관리) |
|
||||||
|
|
||||||
## 관련 폴더
|
## 관련 폴더
|
||||||
|
|||||||
293
rules/item-policy.md
Normal file
293
rules/item-policy.md
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
# 품목(Items) 비즈니스 정책
|
||||||
|
|
||||||
|
> 품목 관리 시스템의 핵심 비즈니스 규칙 정의
|
||||||
|
>
|
||||||
|
> **최종 업데이트**: 2025-12-09
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 품목 유형 체계 (item_type)
|
||||||
|
|
||||||
|
### 1.1 품목 유형 코드 정의
|
||||||
|
|
||||||
|
| 코드 | 한글명 | 영문명 | source_table | 설명 |
|
||||||
|
|------|--------|--------|--------------|------|
|
||||||
|
| `FG` | 완제품 | Finished Goods | products | 판매 가능한 최종 제품 |
|
||||||
|
| `PT` | 부품 | Parts | products | 제품 구성에 사용되는 부품 |
|
||||||
|
| `SM` | 부자재 | Sub-Materials | materials | 생산에 사용되는 보조 자재 |
|
||||||
|
| `RM` | 원자재 | Raw Materials | materials | 생산의 주요 원료 |
|
||||||
|
| `CS` | 소모품 | Consumables | materials | 일회성 소모 자재 |
|
||||||
|
|
||||||
|
### 1.2 저장 위치
|
||||||
|
|
||||||
|
```
|
||||||
|
common_codes 테이블
|
||||||
|
├─ code_group = 'item_type'
|
||||||
|
├─ code = 'FG' | 'PT' | 'SM' | 'RM' | 'CS'
|
||||||
|
└─ attributes.source_table = 'products' | 'materials'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.3 source_table 매핑 규칙
|
||||||
|
|
||||||
|
```
|
||||||
|
item_type → source_table 자동 매핑:
|
||||||
|
|
||||||
|
FG (완제품) ─┐
|
||||||
|
PT (부품) ─┴─→ products 테이블
|
||||||
|
|
||||||
|
SM (부자재) ─┐
|
||||||
|
RM (원자재) ─┼─→ materials 테이블
|
||||||
|
CS (소모품) ─┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.4 테넌트별 확장
|
||||||
|
|
||||||
|
- 품목 유형은 테넌트별로 커스터마이징 가능
|
||||||
|
- `common_codes.attributes` JSON 필드 활용 (스키마 변경 없음)
|
||||||
|
- 새 품목 유형 추가 시 source_table 매핑 필수
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 용어 정의 및 구분
|
||||||
|
|
||||||
|
### 2.1 핵심 용어
|
||||||
|
|
||||||
|
| 용어 | 필드명 | 값 | 용도 |
|
||||||
|
|------|--------|-----|------|
|
||||||
|
| **품목 유형** | `item_type` | FG, PT, SM, RM, CS | API 파라미터, UI 필터링, 비즈니스 분류 |
|
||||||
|
| **저장 테이블** | `source_table` | products, materials | 내부 DB 분기, 서비스 로직 |
|
||||||
|
| **참조 타입** | `ref_type` | PRODUCT, MATERIAL | 폴리모픽 관계 (BOM, Prices 등) |
|
||||||
|
|
||||||
|
### 2.2 사용 규칙
|
||||||
|
|
||||||
|
- **API 레벨**: `item_type` 파라미터 사용
|
||||||
|
- **서비스 레벨**: `source_table`로 테이블 분기
|
||||||
|
- **폴리모픽 관계**: `ref_type`으로 참조 (기존 호환성 유지)
|
||||||
|
|
||||||
|
### 2.3 API 흐름 예시
|
||||||
|
|
||||||
|
```
|
||||||
|
1. 클라이언트 요청: GET /api/v1/items?item_type=FG
|
||||||
|
↓
|
||||||
|
2. 서버 처리: item_type='FG' → common_codes 조회
|
||||||
|
↓
|
||||||
|
3. 테이블 분기: source_table='products' 확인
|
||||||
|
↓
|
||||||
|
4. 데이터 조회: products 테이블에서 조회
|
||||||
|
↓
|
||||||
|
5. 응답 반환: item_type='FG' 포함하여 응답
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 필드 키 예약어 정책
|
||||||
|
|
||||||
|
### 3.1 products 테이블 예약어
|
||||||
|
|
||||||
|
```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'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.2 materials 테이블 예약어
|
||||||
|
|
||||||
|
```php
|
||||||
|
// 사용 불가 field_key 목록
|
||||||
|
'name', 'item_name', 'specification', 'material_code', 'material_type',
|
||||||
|
'unit', 'category_id', 'is_inspection', 'is_active',
|
||||||
|
'search_tag', 'remarks', 'attributes', 'options'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.3 공통 시스템 컬럼 (모든 테이블)
|
||||||
|
|
||||||
|
```php
|
||||||
|
// 절대 사용 불가
|
||||||
|
'id', 'tenant_id', 'created_by', 'updated_by', 'deleted_by',
|
||||||
|
'created_at', 'updated_at', 'deleted_at'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.4 검증 규칙
|
||||||
|
|
||||||
|
1. **field_key 저장**: 입력값 그대로 저장 (id 접두사 없음)
|
||||||
|
2. **예약어 검증 흐름**:
|
||||||
|
```
|
||||||
|
field_key 입력
|
||||||
|
↓
|
||||||
|
source_table 확인 (products / materials)
|
||||||
|
↓
|
||||||
|
해당 테이블 예약어 체크
|
||||||
|
↓
|
||||||
|
기존 필드 중복 체크
|
||||||
|
↓
|
||||||
|
저장
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **에러 메시지**:
|
||||||
|
- 예약어 충돌: `"{field_key}"은(는) 시스템 예약어로 사용할 수 없습니다.`
|
||||||
|
- 중복: `field_key은(는) 이미 사용 중입니다.`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. API 파라미터 규칙
|
||||||
|
|
||||||
|
### 4.1 목록 조회 (GET /api/v1/items)
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `type` | ❌ | FG,PT,SM,RM,CS | 품목 유형 필터 (쉼표 구분) |
|
||||||
|
| `search` | ❌ | string | 코드/명칭 검색 |
|
||||||
|
| `page` | ❌ | int | 페이지 번호 |
|
||||||
|
| `size` | ❌ | int | 페이지 크기 |
|
||||||
|
|
||||||
|
### 4.2 단건 조회 (GET /api/v1/items/{id})
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `item_type` | ✅ | FG/PT/SM/RM/CS | 품목 유형 (테이블 분기용) |
|
||||||
|
| `include_price` | ❌ | boolean | 단가 정보 포함 |
|
||||||
|
|
||||||
|
### 4.3 생성 (POST /api/v1/items)
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `product_type` | ✅ | FG/PT/SM/RM/CS | 품목 유형 |
|
||||||
|
| `code` | ✅ | string | 품목 코드 |
|
||||||
|
| `name` | ✅ | string | 품목명 |
|
||||||
|
| `unit` | ✅ | string | 단위 |
|
||||||
|
|
||||||
|
### 4.4 수정 (PUT /api/v1/items/{id})
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `item_type` | ✅ | FG/PT/SM/RM/CS | 품목 유형 (테이블 분기용) |
|
||||||
|
|
||||||
|
### 4.5 삭제 (DELETE /api/v1/items/{id})
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `item_type` | ✅ | FG/PT/SM/RM/CS | 품목 유형 (테이블 분기용) |
|
||||||
|
|
||||||
|
### 4.6 일괄 삭제 (DELETE /api/v1/items/batch)
|
||||||
|
|
||||||
|
| 파라미터 | 필수 | 값 | 설명 |
|
||||||
|
|---------|:----:|-----|------|
|
||||||
|
| `item_type` | ✅ | FG/PT/SM/RM/CS | 품목 유형 |
|
||||||
|
| `ids` | ✅ | array | 삭제할 ID 목록 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 데이터 저장 규칙
|
||||||
|
|
||||||
|
### 5.1 저장 방식 구분
|
||||||
|
|
||||||
|
| 저장 방식 | 대상 | 설명 |
|
||||||
|
|----------|------|------|
|
||||||
|
| **column** | 고정 컬럼 | DB 테이블 컬럼에 직접 저장 |
|
||||||
|
| **json** | 동적 속성 | `attributes` JSON 필드에 저장 |
|
||||||
|
|
||||||
|
### 5.2 고정 컬럼 (column)
|
||||||
|
|
||||||
|
- DB 스키마에 정의된 컬럼
|
||||||
|
- 필드 매핑: `item_fields.source_column` 사용
|
||||||
|
- 예: code, name, unit, category_id 등
|
||||||
|
|
||||||
|
### 5.3 동적 속성 (json)
|
||||||
|
|
||||||
|
- `attributes` JSON 필드에 저장
|
||||||
|
- 필드 매핑: `item_fields.json_path` 사용
|
||||||
|
- 예: `attributes.custom_size`, `attributes.color` 등
|
||||||
|
|
||||||
|
### 5.4 API 응답 규칙
|
||||||
|
|
||||||
|
- **플랫 구조**: attributes 내부 값을 최상위로 전개
|
||||||
|
- **매핑 정보 미노출**: source_table, source_column 등 내부 필드 숨김
|
||||||
|
|
||||||
|
```json
|
||||||
|
// 응답 예시
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"item_type": "FG",
|
||||||
|
"code": "P-001",
|
||||||
|
"name": "스크린 제품",
|
||||||
|
"color": "white", // attributes.color → 플랫 전개
|
||||||
|
"size": "100x200" // attributes.size → 플랫 전개
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 삭제 규칙
|
||||||
|
|
||||||
|
### 6.1 BOM 사용 체크
|
||||||
|
|
||||||
|
- 품목이 다른 BOM의 구성품으로 사용 중이면 삭제 불가
|
||||||
|
- 에러 메시지: `다른 BOM의 구성품으로 사용 중입니다. (N건)`
|
||||||
|
|
||||||
|
### 6.2 Soft Delete
|
||||||
|
|
||||||
|
- 모든 품목은 soft delete 방식 사용
|
||||||
|
- `deleted_at` 타임스탬프로 삭제 표시
|
||||||
|
- 복구 가능
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. 관련 파일
|
||||||
|
|
||||||
|
### 7.1 API 파일
|
||||||
|
|
||||||
|
| 파일 | 경로 | 역할 |
|
||||||
|
|------|------|------|
|
||||||
|
| ItemsController | `api/app/Http/Controllers/Api/V1/ItemsController.php` | API 컨트롤러 |
|
||||||
|
| ItemsService | `api/app/Services/ItemsService.php` | 비즈니스 로직 |
|
||||||
|
| ItemTypeHelper | `api/app/Helpers/ItemTypeHelper.php` | item_type 헬퍼 |
|
||||||
|
| SystemFields | `api/app/Constants/SystemFields.php` | 예약어 상수 |
|
||||||
|
|
||||||
|
### 7.2 Seeder 파일
|
||||||
|
|
||||||
|
| 파일 | 경로 | 역할 |
|
||||||
|
|------|------|------|
|
||||||
|
| ItemTypeSeeder | `api/database/seeders/ItemTypeSeeder.php` | item_type 코드 시딩 |
|
||||||
|
|
||||||
|
### 7.3 Request 파일
|
||||||
|
|
||||||
|
| 파일 | 경로 |
|
||||||
|
|------|------|
|
||||||
|
| ItemStoreRequest | `api/app/Http/Requests/Item/ItemStoreRequest.php` |
|
||||||
|
| ItemUpdateRequest | `api/app/Http/Requests/Item/ItemUpdateRequest.php` |
|
||||||
|
| ItemBatchDeleteRequest | `api/app/Http/Requests/Item/ItemBatchDeleteRequest.php` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. 구현 현황
|
||||||
|
|
||||||
|
### 8.1 완료 항목
|
||||||
|
|
||||||
|
- ✅ item_type 코드 시딩 (ItemTypeSeeder)
|
||||||
|
- ✅ common_codes에 attributes.source_table 매핑
|
||||||
|
- ✅ field_key 예약어 검증 (SystemFields)
|
||||||
|
- ✅ ItemMaster CRUD API (Pages, Sections, Fields)
|
||||||
|
- ✅ 독립 엔티티 아키텍처 (entity_relationships)
|
||||||
|
|
||||||
|
### 8.2 개발 필요 항목
|
||||||
|
|
||||||
|
| API | Product | Material | 작업 내용 |
|
||||||
|
|-----|:-------:|:--------:|----------|
|
||||||
|
| `PUT /items/{id}` | ✅ | ❌ | Material 수정 지원 추가 |
|
||||||
|
| `DELETE /items/{id}` | ✅ | ❌ | Material 삭제 지원 추가 |
|
||||||
|
| `DELETE /items/batch` | ✅ | ❌ | Material 일괄삭제 지원 |
|
||||||
|
| `GET /items/code/{code}` | ✅ | ❌ | Material 코드 조회 지원 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 변경 이력
|
||||||
|
|
||||||
|
| 날짜 | 내용 |
|
||||||
|
|------|------|
|
||||||
|
| 2025-12-09 | 문서 생성 - 4개 문서 통합 (items-api-unified-plan, field-integration, field-key-validation, INDEX) |
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
# Item Master 문서 인덱스
|
|
||||||
|
|
||||||
> 품목기준관리(ItemMaster) 관련 문서 현황 및 개발 상태
|
|
||||||
>
|
|
||||||
> **최종 업데이트**: 2025-12-09
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔑 핵심 개념 정의
|
|
||||||
|
|
||||||
### item_type (품목 유형 코드)
|
|
||||||
|
|
||||||
| 코드 | 한글명 | 영문명 | source_table |
|
|
||||||
|------|--------|--------|--------------|
|
|
||||||
| `FG` | 제품 | Finished Goods | products |
|
|
||||||
| `PT` | 부품 | Parts | products |
|
|
||||||
| `SM` | 부자재 | Sub-Materials | materials |
|
|
||||||
| `RM` | 원자재 | Raw Materials | materials |
|
|
||||||
| `CS` | 소모품 | Consumables | materials |
|
|
||||||
|
|
||||||
> **저장 위치**: `common_codes` 테이블 (`code_group = 'item_type'`)
|
|
||||||
> **소스 테이블 매핑**: `attributes.source_table` JSON 필드
|
|
||||||
> **시딩 상태**: ✅ 구현 완료 (`ItemTypeSeeder.php`)
|
|
||||||
|
|
||||||
### 관련 용어 구분
|
|
||||||
|
|
||||||
| 용어 | 역할 | 값 | 사용처 |
|
|
||||||
|------|------|-----|--------|
|
|
||||||
| `item_type` | 품목 유형 코드 | FG/PT/SM/RM/CS | API 파라미터, 필터링, UI 표시 |
|
|
||||||
| `source_table` | 물리적 저장 테이블 | products/materials | DB 조회, 서비스 로직 분기 |
|
|
||||||
| `ref_type` | 폴리모픽 참조 타입 | PRODUCT/MATERIAL | 기존 폴리모픽 관계 유지 |
|
|
||||||
|
|
||||||
### 매핑 규칙
|
|
||||||
|
|
||||||
```
|
|
||||||
item_type → source_table 자동 매핑:
|
|
||||||
├─ FG, PT → products 테이블
|
|
||||||
└─ SM, RM, CS → materials 테이블
|
|
||||||
|
|
||||||
API 흐름:
|
|
||||||
1. 클라이언트: item_type=FG 전송
|
|
||||||
2. 서버: common_codes에서 source_table 조회
|
|
||||||
3. 서버: products 또는 materials 테이블에 저장/조회
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📐 문서 관계도
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────┐
|
|
||||||
│ Item Master 문서 체계 │
|
|
||||||
├─────────────────────────────────────────────────────────────────┤
|
|
||||||
│ │
|
|
||||||
│ ┌─────────────────┐ 참조 ┌─────────────────────────────┐│
|
|
||||||
│ │ API 가이드 │◄──────────│ items-api-unified-plan.md ││
|
|
||||||
│ │ (front/) │ │ (plans/) ││
|
|
||||||
│ │ │ │ - API 구현 계획 ││
|
|
||||||
│ │ 프론트엔드용 │ │ - item_type 값 변경 스펙 ││
|
|
||||||
│ │ API 명세 │ │ - Swagger 스키마 정의 ││
|
|
||||||
│ └────────┬────────┘ └──────────────┬──────────────┘│
|
|
||||||
│ │ │ │
|
|
||||||
│ │ 연동 │ 구현 기반 │
|
|
||||||
│ ▼ ▼ │
|
|
||||||
│ ┌─────────────────┐ ┌─────────────────────────────┐│
|
|
||||||
│ │ field-integration│ │ field-key-validation.md ││
|
|
||||||
│ │ (specs/) │◄───────────│ (specs/) ││
|
|
||||||
│ │ │ 검증 정책 │ ││
|
|
||||||
│ │ - 필드 통합 설계 │ │ - SystemFields 상수 ││
|
|
||||||
│ │ - source_table │ │ - 예약어 검증 로직 ││
|
|
||||||
│ │ 기반 분기 │ │ - 에러 메시지 정의 ││
|
|
||||||
│ └─────────────────┘ └─────────────────────────────┘│
|
|
||||||
│ │
|
|
||||||
│ ════════════════════════════════════════════════════════════ │
|
|
||||||
│ 공통 기반: common_codes 테이블 (code_group='item_type') │
|
|
||||||
│ ════════════════════════════════════════════════════════════ │
|
|
||||||
└─────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📋 문서 구조
|
|
||||||
|
|
||||||
```
|
|
||||||
docs/
|
|
||||||
├── front/
|
|
||||||
│ └── item-master-guide.md ✅ 최신 API 가이드
|
|
||||||
├── specs/
|
|
||||||
│ ├── ITEM-MASTER-INDEX.md 📋 이 파일
|
|
||||||
│ ├── item-master-integration.md 🔧 연동 설계서 (개발 중)
|
|
||||||
│ ├── item-master-field-integration.md 📄 필드 통합 스펙
|
|
||||||
│ └── item-master-field-key-validation.md ✅ 검증 정책 (구현 완료)
|
|
||||||
├── plans/
|
|
||||||
│ ├── items-api-unified-plan.md 📄 Items API 통합 계획 (최신)
|
|
||||||
│ ├── items-api-modification-plan.md 📦 API 수정 계획 (통합됨)
|
|
||||||
│ ├── items-naming-convention.md 📄 명명 규칙
|
|
||||||
│ └── flow-tests/
|
|
||||||
│ └── item-master-*.json 🧪 API 테스트 플로우
|
|
||||||
├── guides/
|
|
||||||
│ └── item-management-migration.md 📄 마이그레이션 가이드
|
|
||||||
├── data/analysis/
|
|
||||||
│ └── item-db-analysis.md 📊 DB 분석
|
|
||||||
└── history/2025-11/
|
|
||||||
├── item-master-spec.md 📦 구버전 스펙
|
|
||||||
├── item-master-gap-analysis.md 📦 갭 분석
|
|
||||||
├── front-requests/ 📦 프론트 요청서 아카이브
|
|
||||||
└── item-master-archived/ 📦 기타 아카이브
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🎯 핵심 문서 (현재 유효)
|
|
||||||
|
|
||||||
| 문서 | 경로 | 역할 | 상태 |
|
|
||||||
|------|------|------|------|
|
|
||||||
| **API 가이드** | `front/item-master-guide.md` | 프론트엔드용 API 명세 | ✅ 최신 |
|
|
||||||
| **API 통합 계획** | `plans/items-api-unified-plan.md` | Items API 통합 구현 계획 | 📄 최신 |
|
|
||||||
| **필드 통합 스펙** | `specs/item-master-field-integration.md` | source_table 기반 필드 설계 | 🔧 v1.3 구현 중 |
|
|
||||||
| **검증 정책** | `specs/item-master-field-key-validation.md` | field_key 검증 로직 | ✅ 구현 완료 |
|
|
||||||
| **연동 설계서** | `specs/item-master-integration.md` | BE-FE 연동 아키텍처 | 🔧 개발 중 |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔴 개발 필요 항목
|
|
||||||
|
|
||||||
### 1. Items API Material 지원 (items-api-modification-plan.md)
|
|
||||||
|
|
||||||
| API | Product | Material | 작업 내용 |
|
|
||||||
|-----|:-------:|:--------:|----------|
|
|
||||||
| `PUT /items/{id}` | ✅ | ❌ | Material 수정 지원 추가 |
|
|
||||||
| `DELETE /items/{id}` | ✅ | ❌ | Material 삭제 지원 추가 |
|
|
||||||
| `DELETE /items/batch` | ✅ | ❌ | Material 일괄삭제 지원 |
|
|
||||||
| `GET /items/code/{code}` | ✅ | ❌ | Material 코드 조회 지원 |
|
|
||||||
|
|
||||||
**관련 파일**:
|
|
||||||
- `api/app/Services/ItemsService.php`
|
|
||||||
- `api/app/Http/Controllers/Api/V1/ItemsController.php`
|
|
||||||
|
|
||||||
### 2. 연동 설계 구현 (item-master-integration.md)
|
|
||||||
|
|
||||||
| 항목 | 상태 | 설명 |
|
|
||||||
|------|------|------|
|
|
||||||
| ItemFieldValidationService | 🔧 개발 중 | attributes 값 검증 서비스 |
|
|
||||||
| Products/Materials 수정 | ⏳ 대기 | 검증 연동 적용 |
|
|
||||||
| field_meta 응답 옵션 | ⏳ 대기 | `?include_field_meta=true` |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ✅ 구현 완료 항목
|
|
||||||
|
|
||||||
### 1. field_key 검증 정책 (item-master-field-key-validation.md)
|
|
||||||
|
|
||||||
- ✅ `SystemFields` 상수 클래스 생성
|
|
||||||
- ✅ 시스템 예약어 검증 로직
|
|
||||||
- ✅ source_table 기반 분기 처리
|
|
||||||
- ✅ 에러 메시지 (`error.field_key_reserved`)
|
|
||||||
|
|
||||||
### 2. ItemMaster CRUD API
|
|
||||||
|
|
||||||
- ✅ Pages, Sections, Fields, BomItems CRUD
|
|
||||||
- ✅ 독립 엔티티 아키텍처
|
|
||||||
- ✅ entity_relationships 링크 테이블
|
|
||||||
- ✅ Lock 기능 (연결 잠금)
|
|
||||||
|
|
||||||
### 3. item_type 코드 시딩 (ItemTypeSeeder)
|
|
||||||
|
|
||||||
- ✅ common_codes 테이블에 item_type 그룹 데이터 시딩
|
|
||||||
- ✅ attributes.source_table JSON 매핑 (products/materials)
|
|
||||||
- ✅ 5개 코드: FG(완제품), PT(부품), SM(부자재), RM(원자재), CS(소모품)
|
|
||||||
|
|
||||||
### 4. DB 구조 확정 (item_pages, item_sections, item_fields)
|
|
||||||
|
|
||||||
- ✅ item_pages 테이블 (페이지 설정) - 이미 존재, source_table 컬럼 포함
|
|
||||||
- ✅ item_sections 테이블 (섹션 설정) - 이미 존재
|
|
||||||
- ✅ item_fields 테이블 (필드 설정) - 이미 존재
|
|
||||||
- ✅ entity_relationships 링크 테이블로 page→section→field 연결
|
|
||||||
|
|
||||||
> **중요**: item_pages는 common_codes로 대체 불가
|
|
||||||
> - common_codes: item_type 마스터 코드 정의 (FG/PT/SM/RM/CS)
|
|
||||||
> - item_pages: UI 페이지 설정 (같은 item_type에 여러 페이지 가능)
|
|
||||||
> - 두 테이블은 역할이 다르며 공존해야 함
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📦 아카이브 (History)
|
|
||||||
|
|
||||||
구버전 문서는 `docs/history/2025-11/`에 보관됨:
|
|
||||||
|
|
||||||
| 폴더 | 내용 |
|
|
||||||
|------|------|
|
|
||||||
| `front-requests/` | 11월 프론트엔드 API 요청서 |
|
|
||||||
| `item-master-archived/` | 분석, 구현, 디자인 문서 |
|
|
||||||
| `item-master-spec.md` | 초기 API 명세 (11-20) |
|
|
||||||
| `item-master-gap-analysis.md` | 갭 분석 문서 |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📊 관련 테스트
|
|
||||||
|
|
||||||
| 파일 | 위치 | 용도 |
|
|
||||||
|------|------|------|
|
|
||||||
| `item-master-init-api-flow.json` | `docs/plans/flow-tests/` | 초기화 API 테스트 |
|
|
||||||
| `item-master-page-api-flow.json` | `docs/plans/flow-tests/` | 페이지 CRUD 테스트 |
|
|
||||||
| `item-master-field-api-flow.json` | `docs/plans/flow-tests/` | 필드 CRUD 테스트 |
|
|
||||||
| `item-fields-is-active-test.json` | `api/docs/api-flows/` | 활성 필터 테스트 |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 🔗 참고 문서
|
|
||||||
|
|
||||||
- **명명 규칙**: `docs/plans/items-naming-convention.md`
|
|
||||||
- **마이그레이션**: `docs/guides/item-management-migration.md`
|
|
||||||
- **DB 분석**: `docs/data/analysis/item-db-analysis.md`
|
|
||||||
- **MES 분석**: `docs/projects/mes/00_baseline/docs_breakdown/api_item_analysis_summary.md`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 변경 이력
|
|
||||||
|
|
||||||
| 날짜 | 내용 |
|
|
||||||
|------|------|
|
|
||||||
| 2025-12-09 | ItemTypeSeeder 구현 완료 (attributes.source_table 추가), DB 구조 확정 기록 추가, field-integration.md v1.3 반영 |
|
|
||||||
| 2025-12-09 | 핵심 개념 정의 (item_type/source_table/ref_type) 추가, 문서 관계도 추가 |
|
|
||||||
| 2025-12-09 | items-api-unified-plan.md 추가, 핵심 문서 테이블 갱신 |
|
|
||||||
| 2025-12-09 | 문서 인덱스 생성, 중복 문서 정리 |
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,200 +0,0 @@
|
|||||||
# Item Master field_key 검증 정책
|
|
||||||
|
|
||||||
## 개요
|
|
||||||
|
|
||||||
field_key 저장 및 검증 정책을 변경하여 시스템 필드(고정 컬럼)와의 충돌을 방지합니다.
|
|
||||||
|
|
||||||
## 변경 사항
|
|
||||||
|
|
||||||
### 1. field_key 저장 정책 변경
|
|
||||||
|
|
||||||
**변경 전:**
|
|
||||||
```
|
|
||||||
field_key = {id}_{입력값}
|
|
||||||
예: 98_code, 99_name
|
|
||||||
```
|
|
||||||
|
|
||||||
**변경 후:**
|
|
||||||
```
|
|
||||||
field_key = {입력값}
|
|
||||||
예: code, name (단, 시스템 예약어는 사용 불가)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. 시스템 필드 예약어 검증 추가
|
|
||||||
|
|
||||||
#### 검증 흐름
|
|
||||||
```
|
|
||||||
field_key 입력
|
|
||||||
↓
|
|
||||||
source_table 확인 (products / materials)
|
|
||||||
↓
|
|
||||||
해당 테이블 예약어 체크
|
|
||||||
↓
|
|
||||||
기존 필드 중복 체크
|
|
||||||
↓
|
|
||||||
저장
|
|
||||||
```
|
|
||||||
|
|
||||||
#### source_table 기반 예약어 매핑
|
|
||||||
|
|
||||||
| source_table | 대상 테이블 | 예약어 목록 |
|
|
||||||
|--------------|-------------|-------------|
|
|
||||||
| `products` | products | code, name, unit, product_type, ... |
|
|
||||||
| `materials` | materials | name, material_code, material_type, ... |
|
|
||||||
| `null` | 전체 | products + materials 예약어 모두 체크 (안전 모드) |
|
|
||||||
|
|
||||||
## 구현 상세
|
|
||||||
|
|
||||||
### 파일 구조
|
|
||||||
|
|
||||||
```
|
|
||||||
app/
|
|
||||||
├── Constants/
|
|
||||||
│ └── SystemFields.php # 신규: 예약어 상수 클래스
|
|
||||||
└── Services/
|
|
||||||
└── ItemMaster/
|
|
||||||
└── ItemFieldService.php # 수정: 예약어 검증 추가
|
|
||||||
```
|
|
||||||
|
|
||||||
### SystemFields 상수 클래스
|
|
||||||
|
|
||||||
```php
|
|
||||||
// app/Constants/SystemFields.php
|
|
||||||
|
|
||||||
class SystemFields
|
|
||||||
{
|
|
||||||
// 소스 테이블 상수
|
|
||||||
public const SOURCE_TABLE_PRODUCTS = 'products';
|
|
||||||
public const SOURCE_TABLE_MATERIALS = 'materials';
|
|
||||||
|
|
||||||
// 그룹 ID 상수
|
|
||||||
public const GROUP_ITEM_MASTER = 1;
|
|
||||||
|
|
||||||
// products 테이블 고정 컬럼
|
|
||||||
public const PRODUCTS = [
|
|
||||||
'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',
|
|
||||||
];
|
|
||||||
|
|
||||||
// materials 테이블 고정 컬럼
|
|
||||||
public const MATERIALS = [
|
|
||||||
'name', 'item_name', 'specification', 'material_code', 'material_type',
|
|
||||||
'unit', 'category_id', 'is_inspection', 'is_active',
|
|
||||||
'search_tag', 'remarks', 'attributes', 'options',
|
|
||||||
];
|
|
||||||
|
|
||||||
// 공통 시스템 컬럼
|
|
||||||
public const COMMON = [
|
|
||||||
'id', 'tenant_id', 'created_by', 'updated_by', 'deleted_by',
|
|
||||||
'created_at', 'updated_at', 'deleted_at',
|
|
||||||
];
|
|
||||||
|
|
||||||
// source_table 기반 예약어 조회
|
|
||||||
public static function getReservedKeys(string $sourceTable): array;
|
|
||||||
|
|
||||||
// 예약어 여부 확인
|
|
||||||
public static function isReserved(string $fieldKey, string $sourceTable): bool;
|
|
||||||
|
|
||||||
// 그룹 내 전체 예약어 조회 (안전 모드)
|
|
||||||
public static function getAllReservedKeysForGroup(int $groupId): array;
|
|
||||||
|
|
||||||
// 그룹 내 예약어 여부 확인
|
|
||||||
public static function isReservedInGroup(string $fieldKey, int $groupId): bool;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### ItemFieldService 검증 메서드
|
|
||||||
|
|
||||||
```php
|
|
||||||
private function validateFieldKeyUnique(
|
|
||||||
string $fieldKey,
|
|
||||||
int $tenantId,
|
|
||||||
?string $sourceTable = null,
|
|
||||||
int $groupId = 1,
|
|
||||||
?int $excludeId = null
|
|
||||||
): void {
|
|
||||||
// 1. 시스템 필드(예약어) 체크
|
|
||||||
if ($sourceTable) {
|
|
||||||
if (SystemFields::isReserved($fieldKey, $sourceTable)) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'field_key' => [__('error.field_key_reserved', ['field_key' => $fieldKey])],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 안전 모드: 그룹 내 모든 테이블 예약어 체크
|
|
||||||
if (SystemFields::isReservedInGroup($fieldKey, $groupId)) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'field_key' => [__('error.field_key_reserved', ['field_key' => $fieldKey])],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 기존 필드 중복 체크
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 호출 예시
|
|
||||||
|
|
||||||
```php
|
|
||||||
// 독립 필드 생성 시
|
|
||||||
$this->validateFieldKeyUnique(
|
|
||||||
$data['field_key'],
|
|
||||||
$tenantId,
|
|
||||||
$data['source_table'] ?? null, // 'products' 또는 'materials'
|
|
||||||
$data['group_id'] ?? 1
|
|
||||||
);
|
|
||||||
|
|
||||||
// 필드 수정 시
|
|
||||||
$this->validateFieldKeyUnique(
|
|
||||||
$data['field_key'],
|
|
||||||
$tenantId,
|
|
||||||
$data['source_table'] ?? null,
|
|
||||||
$field->group_id ?? 1,
|
|
||||||
$id // excludeId
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
## 에러 메시지
|
|
||||||
|
|
||||||
| 상황 | 메시지 키 | 메시지 |
|
|
||||||
|------|----------|--------|
|
|
||||||
| 시스템 예약어 충돌 | `error.field_key_reserved` | `"code"은(는) 시스템 예약어로 사용할 수 없습니다.` |
|
|
||||||
| 기존 필드 중복 | `validation.unique` | `field_key은(는) 이미 사용 중입니다.` |
|
|
||||||
|
|
||||||
```php
|
|
||||||
// lang/ko/error.php
|
|
||||||
'field_key_reserved' => '":field_key"은(는) 시스템 예약어로 사용할 수 없습니다.',
|
|
||||||
|
|
||||||
// lang/ko/validation.php (Laravel 기본)
|
|
||||||
'unique' => ':attribute은(는) 이미 사용 중입니다.',
|
|
||||||
```
|
|
||||||
|
|
||||||
## clone 메서드 field_key 복제 정책
|
|
||||||
|
|
||||||
```
|
|
||||||
원본 field_key: custom_field
|
|
||||||
복제본: custom_field_copy
|
|
||||||
|
|
||||||
중복 시: custom_field_copy2, custom_field_copy3, ...
|
|
||||||
```
|
|
||||||
|
|
||||||
## 관련 파일
|
|
||||||
|
|
||||||
| 파일 | 변경 유형 | 설명 |
|
|
||||||
|------|----------|------|
|
|
||||||
| `app/Constants/SystemFields.php` | 신규 | 예약어 상수 클래스 |
|
|
||||||
| `app/Services/ItemMaster/ItemFieldService.php` | 수정 | 검증 로직 추가 |
|
|
||||||
| `lang/ko/error.php` | 수정 | 에러 메시지 추가 |
|
|
||||||
|
|
||||||
## 참고
|
|
||||||
|
|
||||||
- ItemPage 테이블의 `source_table` 컬럼: 실제 저장 테이블명 (products, materials)
|
|
||||||
- ItemPage 테이블의 `item_type` 컬럼: FG, PT, SM, RM, CS (품목 유형 코드)
|
|
||||||
- `group_id`: 카테고리 격리용 (1 = 품목관리)
|
|
||||||
Reference in New Issue
Block a user