feat: ItemMaster Phase 1 API 구현 (핵심 기능 13개 엔드포인트)
- Controller 4개 생성 (ItemMaster, ItemPage, ItemSection, ItemField)
- Service 4개 생성 (비즈니스 로직 및 Multi-tenant 지원)
- FormRequest 7개 생성 (Validation)
- Routes 등록 (/v1/item-master/*)
주요 API:
- GET /init - 전체 초기 데이터 로드
- 페이지 관리 (GET/POST/PUT/DELETE)
- 섹션 관리 (POST/PUT/DELETE/reorder)
- 필드 관리 (POST/PUT/DELETE/reorder)
기술적 특징:
- Service-First 패턴 (Controller는 DI + ApiResponse만)
- Multi-tenant 지원 (tenantId() 검증 + BelongsToTenant)
- Cascade Soft Delete (하위 엔티티 자동 처리)
- i18n 메시지 키 사용 (__('message.xxx'))
- order_no 자동 계산 및 reorder 지원
검증:
- 라우트 테스트: 13개 엔드포인트 정상 등록
- Pint 검사: 15 files PASS
SAM API Development Rules 준수
This commit is contained in:
64
app/Services/ItemMaster/ItemMasterService.php
Normal file
64
app/Services/ItemMaster/ItemMasterService.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ItemMaster;
|
||||
|
||||
use App\Models\ItemMaster\CustomTab;
|
||||
use App\Models\ItemMaster\ItemMasterField;
|
||||
use App\Models\ItemMaster\ItemPage;
|
||||
use App\Models\ItemMaster\SectionTemplate;
|
||||
use App\Models\ItemMaster\UnitOption;
|
||||
use App\Services\Service;
|
||||
|
||||
class ItemMasterService extends Service
|
||||
{
|
||||
/**
|
||||
* 초기화 데이터 로드
|
||||
*
|
||||
* - pages (섹션/필드 중첩)
|
||||
* - sectionTemplates
|
||||
* - masterFields
|
||||
* - customTabs (columnSetting 포함)
|
||||
* - unitOptions
|
||||
*/
|
||||
public function init(): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
|
||||
// 1. 페이지 (섹션 → 필드 중첩)
|
||||
$pages = ItemPage::with([
|
||||
'sections' => function ($query) {
|
||||
$query->orderBy('order_no');
|
||||
},
|
||||
'sections.fields' => function ($query) {
|
||||
$query->orderBy('order_no');
|
||||
},
|
||||
'sections.bomItems',
|
||||
])
|
||||
->where('tenant_id', $tenantId)
|
||||
->where('is_active', 1)
|
||||
->get();
|
||||
|
||||
// 2. 섹션 템플릿
|
||||
$sectionTemplates = SectionTemplate::where('tenant_id', $tenantId)->get();
|
||||
|
||||
// 3. 마스터 필드
|
||||
$masterFields = ItemMasterField::where('tenant_id', $tenantId)->get();
|
||||
|
||||
// 4. 커스텀 탭 (컬럼 설정 포함)
|
||||
$customTabs = CustomTab::with('columnSetting')
|
||||
->where('tenant_id', $tenantId)
|
||||
->orderBy('order_no')
|
||||
->get();
|
||||
|
||||
// 5. 단위 옵션
|
||||
$unitOptions = UnitOption::where('tenant_id', $tenantId)->get();
|
||||
|
||||
return [
|
||||
'pages' => $pages,
|
||||
'sectionTemplates' => $sectionTemplates,
|
||||
'masterFields' => $masterFields,
|
||||
'customTabs' => $customTabs,
|
||||
'unitOptions' => $unitOptions,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user