feat: [시공관리] 계약관리 API 구현

- Contract 모델, 마이그레이션 추가
- ContractController CRUD 엔드포인트 구현
- ContractService 비즈니스 로직 구현
- ContractStoreRequest, ContractUpdateRequest 검증 추가
- Swagger API 문서 작성
- 라우트 등록 (GET/POST/PUT/DELETE)
- 통계 및 단계별 건수 조회 API 추가

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-09 10:18:43 +09:00
parent 349917f019
commit 3a8af2d7ee
9 changed files with 1188 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Http\Requests\Construction;
use App\Models\Construction\Contract;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ContractStoreRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// 기본 정보
'contract_code' => 'required|string|max:50',
'project_name' => 'required|string|max:255',
// 거래처 정보
'partner_id' => 'nullable|integer',
'partner_name' => 'nullable|string|max:255',
// 담당자 정보
'contract_manager_id' => 'nullable|integer',
'contract_manager_name' => 'nullable|string|max:100',
'construction_pm_id' => 'nullable|integer',
'construction_pm_name' => 'nullable|string|max:100',
// 계약 상세
'total_locations' => 'nullable|integer|min:0',
'contract_amount' => 'nullable|numeric|min:0',
'contract_start_date' => 'nullable|date',
'contract_end_date' => 'nullable|date|after_or_equal:contract_start_date',
// 상태 정보
'status' => [
'nullable',
Rule::in([Contract::STATUS_PENDING, Contract::STATUS_COMPLETED]),
],
'stage' => [
'nullable',
Rule::in([
Contract::STAGE_ESTIMATE_SELECTED,
Contract::STAGE_ESTIMATE_PROGRESS,
Contract::STAGE_DELIVERY,
Contract::STAGE_INSTALLATION,
Contract::STAGE_INSPECTION,
Contract::STAGE_OTHER,
]),
],
// 연결 정보
'bidding_id' => 'nullable|integer',
'bidding_code' => 'nullable|string|max:50',
// 기타
'remarks' => 'nullable|string',
'is_active' => 'nullable|boolean',
];
}
public function messages(): array
{
return [
'contract_code.required' => __('validation.required', ['attribute' => '계약번호']),
'contract_code.max' => __('validation.max.string', ['attribute' => '계약번호', 'max' => 50]),
'project_name.required' => __('validation.required', ['attribute' => '현장명']),
'contract_end_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '계약종료일', 'date' => '계약시작일']),
];
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Http\Requests\Construction;
use App\Models\Construction\Contract;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ContractUpdateRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// 기본 정보
'contract_code' => 'sometimes|string|max:50',
'project_name' => 'sometimes|string|max:255',
// 거래처 정보
'partner_id' => 'nullable|integer',
'partner_name' => 'nullable|string|max:255',
// 담당자 정보
'contract_manager_id' => 'nullable|integer',
'contract_manager_name' => 'nullable|string|max:100',
'construction_pm_id' => 'nullable|integer',
'construction_pm_name' => 'nullable|string|max:100',
// 계약 상세
'total_locations' => 'nullable|integer|min:0',
'contract_amount' => 'nullable|numeric|min:0',
'contract_start_date' => 'nullable|date',
'contract_end_date' => 'nullable|date|after_or_equal:contract_start_date',
// 상태 정보
'status' => [
'nullable',
Rule::in([Contract::STATUS_PENDING, Contract::STATUS_COMPLETED]),
],
'stage' => [
'nullable',
Rule::in([
Contract::STAGE_ESTIMATE_SELECTED,
Contract::STAGE_ESTIMATE_PROGRESS,
Contract::STAGE_DELIVERY,
Contract::STAGE_INSTALLATION,
Contract::STAGE_INSPECTION,
Contract::STAGE_OTHER,
]),
],
// 연결 정보
'bidding_id' => 'nullable|integer',
'bidding_code' => 'nullable|string|max:50',
// 기타
'remarks' => 'nullable|string',
'is_active' => 'nullable|boolean',
];
}
public function messages(): array
{
return [
'contract_code.max' => __('validation.max.string', ['attribute' => '계약번호', 'max' => 50]),
'contract_end_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '계약종료일', 'date' => '계약시작일']),
];
}
}