feat: 품목 마스터 소스 매핑 기능 추가

- ItemField 모델: 소스 매핑 컬럼 추가 (source_table, source_column 등)
- ItemPage 모델: source_table 컬럼 추가
- ItemDataService: 동적 데이터 조회 서비스
- ItemMasterApi Swagger 업데이트
- ItemTypeSeeder: 품목 유형 시더
- 스펙 문서: ITEM_MASTER_FIELD_INTEGRATION_PLAN.md
This commit is contained in:
2025-12-09 09:39:16 +09:00
parent 46d4c30880
commit bf92b37ff6
8 changed files with 1950 additions and 370 deletions

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('item_pages', function (Blueprint $table) {
// source_table 컬럼 추가
$table->string('source_table', 100)
->nullable()
->after('item_type')
->comment('실제 저장 테이블명 (products, materials 등)');
// 인덱스
$table->index('source_table', 'idx_source_table');
});
// 기존 데이터 업데이트: item_type 기반으로 source_table 설정
DB::table('item_pages')
->whereIn('item_type', ['FG', 'PT'])
->update(['source_table' => 'products']);
DB::table('item_pages')
->whereIn('item_type', ['SM', 'RM', 'CS'])
->update(['source_table' => 'materials']);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('item_pages', function (Blueprint $table) {
$table->dropIndex('idx_source_table');
$table->dropColumn('source_table');
});
}
};

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('item_fields', function (Blueprint $table) {
// 내부용 매핑 컬럼 (API 응답에서 제외)
$table->string('source_table', 100)
->nullable()
->after('properties')
->comment('내부용: 원본 테이블명 (products, materials 등)');
$table->string('source_column', 100)
->nullable()
->after('source_table')
->comment('내부용: 원본 컬럼명 (code, name 등)');
$table->enum('storage_type', ['column', 'json'])
->default('json')
->after('source_column')
->comment('내부용: 저장방식 (column=DB컬럼, json=attributes/options)');
$table->string('json_path', 200)
->nullable()
->after('storage_type')
->comment('내부용: JSON 저장 경로 (예: attributes.custom_size)');
// 인덱스
$table->index(['source_table', 'source_column'], 'idx_source_mapping');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('item_fields', function (Blueprint $table) {
$table->dropIndex('idx_source_mapping');
$table->dropColumn(['source_table', 'source_column', 'storage_type', 'json_path']);
});
}
};