- Products 테이블에 9개 파일 관련 필드 추가
- bending_diagram, bending_details (JSON)
- specification_file, specification_file_name
- certification_file, certification_file_name
- certification_number, certification_start_date, certification_end_date
- ItemsFileController 구현 (Code-based API)
- POST /items/{code}/files - 파일 업로드
- DELETE /items/{code}/files/{type} - 파일 삭제
- 파일 타입: bending_diagram, specification, certification
- ItemsFileUploadRequest 검증
- 파일 타입별 MIME 검증 (이미지/문서)
- 파일 크기 제한 (10MB/20MB)
- 인증 정보 및 절곡 상세 정보 검증
- Swagger 문서 작성 (ItemsFileApi.php)
- 업로드/삭제 API 스펙
- 스키마: ItemFileUploadResponse, ItemFileDeleteResponse
202 lines
6.7 KiB
PHP
202 lines
6.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Commons\Menu;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* 새 테넌트를 위한 기본 메뉴 생성 서비스
|
|
*/
|
|
class MenuBootstrapService
|
|
{
|
|
/**
|
|
* 글로벌 메뉴 템플릿을 테넌트에 복제
|
|
*
|
|
* @param int $tenantId 테넌트 ID
|
|
* @return array 생성된 메뉴 ID 목록
|
|
*/
|
|
public static function cloneGlobalMenusForTenant(int $tenantId): array
|
|
{
|
|
return DB::transaction(function () use ($tenantId) {
|
|
// 1. 글로벌 템플릿 메뉴 조회 (parent_id 순서대로 정렬)
|
|
$templateMenus = Menu::withoutGlobalScopes()
|
|
->whereNull('tenant_id')
|
|
->orderByRaw('COALESCE(parent_id, 0)')
|
|
->orderBy('sort_order')
|
|
->get();
|
|
|
|
// 2. parent_id 매핑 테이블 생성
|
|
$idMapping = [];
|
|
$menuIds = [];
|
|
|
|
// 3. 계층 순서대로 복제 (parent → child)
|
|
foreach ($templateMenus as $template) {
|
|
$newMenu = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $template->parent_id
|
|
? ($idMapping[$template->parent_id] ?? null)
|
|
: null,
|
|
'name' => $template->name,
|
|
'url' => $template->url,
|
|
'icon' => $template->icon,
|
|
'sort_order' => $template->sort_order,
|
|
'is_active' => $template->is_active,
|
|
'hidden' => $template->hidden,
|
|
'is_external' => $template->is_external,
|
|
'external_url' => $template->external_url,
|
|
]);
|
|
|
|
// 4. ID 매핑 저장
|
|
$idMapping[$template->id] = $newMenu->id;
|
|
$menuIds[] = $newMenu->id;
|
|
}
|
|
|
|
return $menuIds;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 테넌트를 위한 기본 메뉴 구조 생성 (구버전 - 하위 호환성 유지)
|
|
*
|
|
* @deprecated Use cloneGlobalMenusForTenant() instead
|
|
*
|
|
* @param int $tenantId 테넌트 ID
|
|
* @return array 생성된 메뉴 ID 목록
|
|
*/
|
|
public static function createDefaultMenus(int $tenantId): array
|
|
{
|
|
return DB::transaction(function () use ($tenantId) {
|
|
$menuIds = [];
|
|
|
|
// 1. 대시보드 (최상위)
|
|
$dashboard = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => null,
|
|
'name' => '대시보드',
|
|
'url' => '/dashboard',
|
|
'is_active' => 1,
|
|
'sort_order' => 1,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'dashboard',
|
|
]);
|
|
$menuIds[] = $dashboard->id;
|
|
|
|
// 2. 기초정보관리 (최상위)
|
|
$baseInfo = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => null,
|
|
'name' => '기초정보관리',
|
|
'url' => '',
|
|
'is_active' => 1,
|
|
'sort_order' => 2,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'folder',
|
|
]);
|
|
$menuIds[] = $baseInfo->id;
|
|
|
|
// 2-1. 제품 관리 (기초정보관리 하위)
|
|
$product = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $baseInfo->id,
|
|
'name' => '제품 관리',
|
|
'url' => '/base/product/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 1,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'inventory',
|
|
]);
|
|
$menuIds[] = $product->id;
|
|
|
|
// 2-2. 거래처 관리 (기초정보관리 하위)
|
|
$client = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $baseInfo->id,
|
|
'name' => '거래처 관리',
|
|
'url' => '/base/client/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 2,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'business',
|
|
]);
|
|
$menuIds[] = $client->id;
|
|
|
|
// 2-3. 모델 및 BOM관리 (기초정보관리 하위)
|
|
$bom = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $baseInfo->id,
|
|
'name' => '모델 및 BOM관리',
|
|
'url' => '/base/bom/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 3,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'assignment',
|
|
]);
|
|
$menuIds[] = $bom->id;
|
|
|
|
// 3. 시스템 관리 (최상위)
|
|
$system = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => null,
|
|
'name' => '시스템 관리',
|
|
'url' => '',
|
|
'is_active' => 1,
|
|
'sort_order' => 3,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'settings',
|
|
]);
|
|
$menuIds[] = $system->id;
|
|
|
|
// 3-1. 사용자 관리 (시스템 관리 하위)
|
|
$user = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $system->id,
|
|
'name' => '사용자 관리',
|
|
'url' => '/system/user/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 1,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'people',
|
|
]);
|
|
$menuIds[] = $user->id;
|
|
|
|
// 3-2. 권한 관리 (시스템 관리 하위)
|
|
$permission = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $system->id,
|
|
'name' => '권한 관리',
|
|
'url' => '/system/permission/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 2,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'lock',
|
|
]);
|
|
$menuIds[] = $permission->id;
|
|
|
|
// 3-3. 부서 관리 (시스템 관리 하위)
|
|
$department = Menu::create([
|
|
'tenant_id' => $tenantId,
|
|
'parent_id' => $system->id,
|
|
'name' => '부서 관리',
|
|
'url' => '/system/department/lists',
|
|
'is_active' => 1,
|
|
'sort_order' => 3,
|
|
'hidden' => 0,
|
|
'is_external' => 0,
|
|
'icon' => 'corporate_fare',
|
|
]);
|
|
$menuIds[] = $department->id;
|
|
|
|
return $menuIds;
|
|
});
|
|
}
|
|
}
|