feat(API): Inspection API 구현
- InspectionController 생성 (CRUD + stats + complete) - InspectionService 생성 (비즈니스 로직) - FormRequest 생성 (Store/Update/Complete) - 라우트 등록 (7개 엔드포인트) - i18n 메시지 추가 (message.php, error.php) 기존 inspections 테이블 및 Inspection 모델 활용 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
30
app/Http/Requests/Inspection/InspectionCompleteRequest.php
Normal file
30
app/Http/Requests/Inspection/InspectionCompleteRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inspection;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class InspectionCompleteRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'result' => ['required', Rule::in(['pass', 'fail'])],
|
||||
'opinion' => ['nullable', 'string', 'max:2000'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'result.required' => __('validation.required', ['attribute' => '검사결과']),
|
||||
'result.in' => __('validation.in', ['attribute' => '검사결과']),
|
||||
];
|
||||
}
|
||||
}
|
||||
47
app/Http/Requests/Inspection/InspectionStoreRequest.php
Normal file
47
app/Http/Requests/Inspection/InspectionStoreRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inspection;
|
||||
|
||||
use App\Models\Qualitys\Inspection;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class InspectionStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'inspection_type' => ['required', Rule::in([
|
||||
Inspection::TYPE_IQC,
|
||||
Inspection::TYPE_PQC,
|
||||
Inspection::TYPE_FQC,
|
||||
])],
|
||||
'lot_no' => ['required', 'string', 'max:50'],
|
||||
'item_name' => ['nullable', 'string', 'max:200'],
|
||||
'process_name' => ['nullable', 'string', 'max:100'],
|
||||
'quantity' => ['nullable', 'numeric', 'min:0'],
|
||||
'unit' => ['nullable', 'string', 'max:20'],
|
||||
'inspector_id' => ['nullable', 'integer', 'exists:users,id'],
|
||||
'remarks' => ['nullable', 'string', 'max:1000'],
|
||||
'items' => ['nullable', 'array'],
|
||||
'items.*.name' => ['required_with:items', 'string', 'max:200'],
|
||||
'items.*.type' => ['required_with:items', Rule::in(['quality', 'measurement'])],
|
||||
'items.*.spec' => ['required_with:items', 'string', 'max:200'],
|
||||
'items.*.unit' => ['nullable', 'string', 'max:20'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'inspection_type.required' => __('validation.required', ['attribute' => '검사유형']),
|
||||
'inspection_type.in' => __('validation.in', ['attribute' => '검사유형']),
|
||||
'lot_no.required' => __('validation.required', ['attribute' => 'LOT번호']),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/Inspection/InspectionUpdateRequest.php
Normal file
28
app/Http/Requests/Inspection/InspectionUpdateRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Inspection;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class InspectionUpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'items' => ['nullable', 'array'],
|
||||
'items.*.id' => ['required_with:items', 'string'],
|
||||
'items.*.result' => ['nullable', 'string', 'max:20'],
|
||||
'items.*.measured_value' => ['nullable', 'numeric'],
|
||||
'items.*.judgment' => ['nullable', Rule::in(['pass', 'fail'])],
|
||||
'result' => ['nullable', Rule::in(['pass', 'fail'])],
|
||||
'remarks' => ['nullable', 'string', 'max:1000'],
|
||||
'opinion' => ['nullable', 'string', 'max:2000'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user