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:
@@ -26,11 +26,26 @@ public function list(Request $request)
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 그룹의 공통 코드 목록 조회
|
||||
*
|
||||
* GET /api/v1/settings/common/{group}
|
||||
*/
|
||||
public function index(Request $request, string $group)
|
||||
{
|
||||
return ApiResponse::handle(function () {
|
||||
// Service implementation needed
|
||||
return [];
|
||||
return ApiResponse::handle(function () use ($group) {
|
||||
$tenantId = app('tenant_id');
|
||||
|
||||
return DB::table('common_codes')
|
||||
->select(['id', 'code', 'name', 'description', 'sort_order', 'attributes'])
|
||||
->where('code_group', $group)
|
||||
->where('is_active', true)
|
||||
->where(function ($query) use ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId)
|
||||
->orWhereNull('tenant_id');
|
||||
})
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
|
||||
@@ -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