fix: P0 Critical 이슈 수정 - 삭제된 Product/Material 참조 제거
- ItemsBomController: ProductBomService 제거, Item.bom JSON 기반으로 재구현 - ItemsFileController: Product/Material → Item 모델로 통합 - ItemPage: products/materials 클래스 매핑 제거 - ItemsService 삭제 (1,210줄) - ItemService로 대체 완료 BOM 기능 변경: - 기존: ProductBomService (삭제됨) - 변경: Item 모델의 bom JSON 필드 직접 조작 - 모든 BOM API 엔드포인트 정상 동작 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,12 +3,10 @@
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Helpers\ItemTypeHelper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Item\ItemFileUploadRequest;
|
||||
use App\Models\Commons\File;
|
||||
use App\Models\Materials\Material;
|
||||
use App\Models\Products\Product;
|
||||
use App\Models\Items\Item;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -37,11 +35,10 @@ public function index(int $id, Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
$tenantId = app('tenant_id');
|
||||
$itemType = strtoupper($request->input('item_type', 'FG'));
|
||||
$fieldKey = $request->input('field_key');
|
||||
|
||||
// 품목 존재 확인
|
||||
$this->getItemById($id, $itemType, $tenantId);
|
||||
$this->getItemById($id, $tenantId);
|
||||
|
||||
// 파일 조회
|
||||
$query = File::query()
|
||||
@@ -76,13 +73,12 @@ public function upload(int $id, ItemFileUploadRequest $request)
|
||||
$tenantId = app('tenant_id');
|
||||
$userId = auth()->id();
|
||||
$validated = $request->validated();
|
||||
$itemType = strtoupper($validated['item_type'] ?? 'FG');
|
||||
$fieldKey = $validated['field_key'];
|
||||
$uploadedFile = $validated['file'];
|
||||
$existingFileId = $validated['file_id'] ?? null;
|
||||
|
||||
// 품목 존재 확인
|
||||
$this->getItemById($id, $itemType, $tenantId);
|
||||
$this->getItemById($id, $tenantId);
|
||||
|
||||
$replaced = false;
|
||||
|
||||
@@ -156,13 +152,12 @@ public function upload(int $id, ItemFileUploadRequest $request)
|
||||
*/
|
||||
public function delete(int $id, int $fileId, Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $fileId, $request) {
|
||||
return ApiResponse::handle(function () use ($id, $fileId) {
|
||||
$tenantId = app('tenant_id');
|
||||
$userId = auth()->id();
|
||||
$itemType = strtoupper($request->input('item_type', 'FG'));
|
||||
|
||||
// 품목 존재 확인
|
||||
$this->getItemById($id, $itemType, $tenantId);
|
||||
$this->getItemById($id, $tenantId);
|
||||
|
||||
// 파일 조회
|
||||
$file = File::query()
|
||||
@@ -187,19 +182,13 @@ public function delete(int $id, int $fileId, Request $request)
|
||||
}
|
||||
|
||||
/**
|
||||
* ID로 품목 조회 (Product 또는 Material)
|
||||
* ID로 품목 조회 (통합 items 테이블)
|
||||
*/
|
||||
private function getItemById(int $id, string $itemType, int $tenantId): Product|Material
|
||||
private function getItemById(int $id, int $tenantId): Item
|
||||
{
|
||||
if (ItemTypeHelper::isMaterial($itemType, $tenantId)) {
|
||||
$item = Material::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->find($id);
|
||||
} else {
|
||||
$item = Product::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->find($id);
|
||||
}
|
||||
$item = Item::query()
|
||||
->where('tenant_id', $tenantId)
|
||||
->find($id);
|
||||
|
||||
if (! $item) {
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
|
||||
Reference in New Issue
Block a user