feat: I-8 휴가 정책 관리 API 구현
- LeavePolicyController: 휴가 정책 CRUD API - LeavePolicyService: 정책 관리 로직 - LeavePolicy 모델: 다중 테넌트 지원 - FormRequest 검증 클래스 - Swagger 문서화 - leave_policies 테이블 마이그레이션 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
41
app/Http/Controllers/Api/V1/LeavePolicyController.php
Normal file
41
app/Http/Controllers/Api/V1/LeavePolicyController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LeavePolicy\UpdateRequest;
|
||||
use App\Services\LeavePolicyService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* 휴가 정책 관리 컨트롤러
|
||||
*/
|
||||
class LeavePolicyController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected LeavePolicyService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 휴가 정책 조회
|
||||
* GET /v1/leave-policy
|
||||
*/
|
||||
public function show(): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () {
|
||||
return $this->service->show();
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 휴가 정책 업데이트
|
||||
* PUT /v1/leave-policy
|
||||
*/
|
||||
public function update(UpdateRequest $request): JsonResponse
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->update($request->validated());
|
||||
}, __('message.updated'));
|
||||
}
|
||||
}
|
||||
41
app/Http/Requests/LeavePolicy/UpdateRequest.php
Normal file
41
app/Http/Requests/LeavePolicy/UpdateRequest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\LeavePolicy;
|
||||
|
||||
use App\Models\Tenants\LeavePolicy;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'standard_type' => ['sometimes', Rule::in(LeavePolicy::STANDARD_TYPES)],
|
||||
'fiscal_start_month' => ['sometimes', 'integer', 'min:1', 'max:12'],
|
||||
'fiscal_start_day' => ['sometimes', 'integer', 'min:1', 'max:31'],
|
||||
'default_annual_leave' => ['sometimes', 'integer', 'min:0', 'max:100'],
|
||||
'additional_leave_per_year' => ['sometimes', 'integer', 'min:0', 'max:10'],
|
||||
'max_annual_leave' => ['sometimes', 'integer', 'min:0', 'max:100'],
|
||||
'carry_over_enabled' => ['sometimes', 'boolean'],
|
||||
'carry_over_max_days' => ['sometimes', 'integer', 'min:0', 'max:100'],
|
||||
'carry_over_expiry_months' => ['sometimes', 'integer', 'min:0', 'max:24'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'standard_type.in' => __('validation.in', ['attribute' => '기준 유형']),
|
||||
'fiscal_start_month.min' => __('validation.min.numeric', ['attribute' => '기준월', 'min' => 1]),
|
||||
'fiscal_start_month.max' => __('validation.max.numeric', ['attribute' => '기준월', 'max' => 12]),
|
||||
'fiscal_start_day.min' => __('validation.min.numeric', ['attribute' => '기준일', 'min' => 1]),
|
||||
'fiscal_start_day.max' => __('validation.max.numeric', ['attribute' => '기준일', 'max' => 31]),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user