feat(common-codes): order_status/order_type 공용 코드 추가
- common_codes 테이블에 order_status 코드 그룹 추가 (DRAFT, CONFIRMED, IN_PROGRESS, COMPLETED, CANCELLED)
- common_codes 테이블에 order_type 코드 그룹 추가 (ORDER, PURCHASE)
- CommonController index 메서드 구현 (GET /api/v1/settings/common/{group})
- 멀티테넌트 지원 (tenant_id NULL 또는 현재 테넌트)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
// order_status 코드 그룹 (수주 상태)
|
||||
$orderStatuses = [
|
||||
['code' => 'DRAFT', 'name' => '임시저장', 'sort_order' => 1],
|
||||
['code' => 'CONFIRMED', 'name' => '확정', 'sort_order' => 2],
|
||||
['code' => 'IN_PROGRESS', 'name' => '진행중', 'sort_order' => 3],
|
||||
['code' => 'COMPLETED', 'name' => '완료', 'sort_order' => 4],
|
||||
['code' => 'CANCELLED', 'name' => '취소', 'sort_order' => 5],
|
||||
];
|
||||
|
||||
foreach ($orderStatuses as $item) {
|
||||
DB::table('common_codes')->updateOrInsert(
|
||||
['code_group' => 'order_status', 'code' => $item['code']],
|
||||
[
|
||||
'code_group' => 'order_status',
|
||||
'code' => $item['code'],
|
||||
'name' => $item['name'],
|
||||
'sort_order' => $item['sort_order'],
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// order_type 코드 그룹 (수주 유형)
|
||||
$orderTypes = [
|
||||
['code' => 'ORDER', 'name' => '수주', 'sort_order' => 1],
|
||||
['code' => 'PURCHASE', 'name' => '발주', 'sort_order' => 2],
|
||||
];
|
||||
|
||||
foreach ($orderTypes as $item) {
|
||||
DB::table('common_codes')->updateOrInsert(
|
||||
['code_group' => 'order_type', 'code' => $item['code']],
|
||||
[
|
||||
'code_group' => 'order_type',
|
||||
'code' => $item['code'],
|
||||
'name' => $item['name'],
|
||||
'sort_order' => $item['sort_order'],
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('common_codes')->where('code_group', 'order_status')->delete();
|
||||
DB::table('common_codes')->where('code_group', 'order_type')->delete();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user