feat: Phase 6.2 팝업관리 API 구현

- popups 테이블 마이그레이션 생성
- Popup 모델 (BelongsToTenant, SoftDeletes)
- PopupService CRUD 구현
- FormRequest 검증 (Store/Update)
- PopupController 6개 엔드포인트
- Swagger 문서 (PopupApi.php)
- PROJECT_DEVELOPMENT_POLICY.md 정책 준수
This commit is contained in:
2025-12-19 16:14:04 +09:00
parent ac551d2c30
commit 8f1292f7c4
10 changed files with 926 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests\V1\Popup;
use App\Models\Popups\Popup;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class StorePopupRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'target_type' => ['sometimes', 'string', Rule::in(array_keys(Popup::TARGET_TYPES))],
'target_id' => ['nullable', 'integer', 'exists:departments,id'],
'title' => ['required', 'string', 'max:200'],
'content' => ['required', 'string'],
'status' => ['sometimes', 'string', Rule::in(array_keys(Popup::STATUSES))],
'started_at' => ['nullable', 'date'],
'ended_at' => ['nullable', 'date', 'after_or_equal:started_at'],
'options' => ['nullable', 'array'],
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'target_type.in' => __('validation.in', ['attribute' => '대상 유형']),
'target_id.exists' => __('validation.exists', ['attribute' => '대상 부서']),
'title.required' => __('validation.required', ['attribute' => '제목']),
'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 200]),
'content.required' => __('validation.required', ['attribute' => '내용']),
'status.in' => __('validation.in', ['attribute' => '상태']),
'ended_at.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '시작일']),
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace App\Http\Requests\V1\Popup;
use App\Models\Popups\Popup;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdatePopupRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'target_type' => ['sometimes', 'string', Rule::in(array_keys(Popup::TARGET_TYPES))],
'target_id' => ['nullable', 'integer', 'exists:departments,id'],
'title' => ['sometimes', 'string', 'max:200'],
'content' => ['sometimes', 'string'],
'status' => ['sometimes', 'string', Rule::in(array_keys(Popup::STATUSES))],
'started_at' => ['nullable', 'date'],
'ended_at' => ['nullable', 'date', 'after_or_equal:started_at'],
'options' => ['nullable', 'array'],
];
}
/**
* Get custom messages for validator errors.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'target_type.in' => __('validation.in', ['attribute' => '대상 유형']),
'target_id.exists' => __('validation.exists', ['attribute' => '대상 부서']),
'title.max' => __('validation.max.string', ['attribute' => '제목', 'max' => 200]),
'status.in' => __('validation.in', ['attribute' => '상태']),
'ended_at.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '시작일']),
];
}
}