feat: [approval] 전자결재 모듈 API 구현
- 마이그레이션 4개 (approval_forms, approval_lines, approvals, approval_steps) - 모델 4개 (ApprovalForm, ApprovalLine, Approval, ApprovalStep) - ApprovalService 비즈니스 로직 (양식/결재선 CRUD, 기안함/결재함/참조함, 결재 액션) - 컨트롤러 3개 (ApprovalFormController, ApprovalLineController, ApprovalController) - FormRequest 13개 (양식/결재선/문서 검증) - Swagger 문서 3개 (26개 엔드포인트) - i18n 메시지/에러 키 추가 - 라우트 26개 등록
This commit is contained in:
29
app/Http/Requests/Approval/FormIndexRequest.php
Normal file
29
app/Http/Requests/Approval/FormIndexRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalForm;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FormIndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$categories = implode(',', ApprovalForm::CATEGORIES);
|
||||
|
||||
return [
|
||||
'category' => "nullable|string|in:{$categories}",
|
||||
'is_active' => 'nullable|boolean',
|
||||
'search' => 'nullable|string|max:100',
|
||||
'sort_by' => 'nullable|string|in:created_at,name,code,category',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Http/Requests/Approval/FormStoreRequest.php
Normal file
44
app/Http/Requests/Approval/FormStoreRequest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalForm;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FormStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$categories = implode(',', ApprovalForm::CATEGORIES);
|
||||
|
||||
return [
|
||||
'name' => 'required|string|max:100',
|
||||
'code' => 'required|string|max:50|regex:/^[a-zA-Z0-9_-]+$/',
|
||||
'category' => "nullable|string|in:{$categories}",
|
||||
'template' => 'required|array',
|
||||
'template.fields' => 'required|array',
|
||||
'template.fields.*.name' => 'required|string|max:50',
|
||||
'template.fields.*.type' => 'required|string|in:text,textarea,number,date,select,checkbox,file',
|
||||
'template.fields.*.label' => 'required|string|max:100',
|
||||
'template.fields.*.required' => 'nullable|boolean',
|
||||
'template.fields.*.options' => 'nullable|array',
|
||||
'is_active' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation.required', ['attribute' => '양식명']),
|
||||
'code.required' => __('validation.required', ['attribute' => '양식코드']),
|
||||
'code.regex' => __('validation.regex', ['attribute' => '양식코드']),
|
||||
'template.required' => __('validation.required', ['attribute' => '템플릿']),
|
||||
'template.fields.required' => __('validation.required', ['attribute' => '필드']),
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Requests/Approval/FormUpdateRequest.php
Normal file
40
app/Http/Requests/Approval/FormUpdateRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalForm;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FormUpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$categories = implode(',', ApprovalForm::CATEGORIES);
|
||||
|
||||
return [
|
||||
'name' => 'nullable|string|max:100',
|
||||
'code' => 'nullable|string|max:50|regex:/^[a-zA-Z0-9_-]+$/',
|
||||
'category' => "nullable|string|in:{$categories}",
|
||||
'template' => 'nullable|array',
|
||||
'template.fields' => 'required_with:template|array',
|
||||
'template.fields.*.name' => 'required_with:template.fields|string|max:50',
|
||||
'template.fields.*.type' => 'required_with:template.fields|string|in:text,textarea,number,date,select,checkbox,file',
|
||||
'template.fields.*.label' => 'required_with:template.fields|string|max:100',
|
||||
'template.fields.*.required' => 'nullable|boolean',
|
||||
'template.fields.*.options' => 'nullable|array',
|
||||
'is_active' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'code.regex' => __('validation.regex', ['attribute' => '양식코드']),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Approval/InboxIndexRequest.php
Normal file
24
app/Http/Requests/Approval/InboxIndexRequest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class InboxIndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'status' => 'nullable|string|in:requested,scheduled,completed,rejected',
|
||||
'sort_by' => 'nullable|string|in:created_at,drafted_at,completed_at,title',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Requests/Approval/IndexRequest.php
Normal file
28
app/Http/Requests/Approval/IndexRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\Approval;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class IndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$statuses = implode(',', Approval::STATUSES);
|
||||
|
||||
return [
|
||||
'status' => "nullable|string|in:{$statuses}",
|
||||
'search' => 'nullable|string|max:100',
|
||||
'sort_by' => 'nullable|string|in:created_at,drafted_at,completed_at,title,status',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Approval/LineIndexRequest.php
Normal file
24
app/Http/Requests/Approval/LineIndexRequest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LineIndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'search' => 'nullable|string|max:100',
|
||||
'sort_by' => 'nullable|string|in:created_at,name,is_default',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
40
app/Http/Requests/Approval/LineStoreRequest.php
Normal file
40
app/Http/Requests/Approval/LineStoreRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalLine;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LineStoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
|
||||
|
||||
return [
|
||||
'name' => 'required|string|max:100',
|
||||
'steps' => 'required|array|min:1',
|
||||
'steps.*.type' => "required|string|in:{$stepTypes}",
|
||||
'steps.*.user_id' => 'required|integer|exists:users,id',
|
||||
'is_default' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'name.required' => __('validation.required', ['attribute' => '결재선명']),
|
||||
'steps.required' => __('validation.required', ['attribute' => '결재단계']),
|
||||
'steps.min' => __('validation.min.array', ['attribute' => '결재단계', 'min' => 1]),
|
||||
'steps.*.type.required' => __('validation.required', ['attribute' => '단계유형']),
|
||||
'steps.*.type.in' => __('validation.in', ['attribute' => '단계유형']),
|
||||
'steps.*.user_id.required' => __('validation.required', ['attribute' => '결재자']),
|
||||
'steps.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']),
|
||||
];
|
||||
}
|
||||
}
|
||||
36
app/Http/Requests/Approval/LineUpdateRequest.php
Normal file
36
app/Http/Requests/Approval/LineUpdateRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalLine;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LineUpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
|
||||
|
||||
return [
|
||||
'name' => 'nullable|string|max:100',
|
||||
'steps' => 'nullable|array|min:1',
|
||||
'steps.*.type' => "required_with:steps|string|in:{$stepTypes}",
|
||||
'steps.*.user_id' => 'required_with:steps|integer|exists:users,id',
|
||||
'is_default' => 'nullable|boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'steps.min' => __('validation.min.array', ['attribute' => '결재단계', 'min' => 1]),
|
||||
'steps.*.type.in' => __('validation.in', ['attribute' => '단계유형']),
|
||||
'steps.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Http/Requests/Approval/ReferenceIndexRequest.php
Normal file
24
app/Http/Requests/Approval/ReferenceIndexRequest.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ReferenceIndexRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'is_read' => 'nullable|boolean',
|
||||
'sort_by' => 'nullable|string|in:created_at,drafted_at,completed_at,title',
|
||||
'sort_dir' => 'nullable|string|in:asc,desc',
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Requests/Approval/RejectRequest.php
Normal file
27
app/Http/Requests/Approval/RejectRequest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RejectRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'comment' => 'required|string|max:1000',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'comment.required' => __('error.approval.reject_comment_required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Requests/Approval/StoreRequest.php
Normal file
43
app/Http/Requests/Approval/StoreRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalLine;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
|
||||
|
||||
return [
|
||||
'form_id' => 'required|integer|exists:approval_forms,id',
|
||||
'title' => 'required|string|max:200',
|
||||
'content' => 'required|array',
|
||||
'attachments' => 'nullable|array',
|
||||
'attachments.*' => 'integer|exists:files,id',
|
||||
'submit' => 'nullable|boolean',
|
||||
'steps' => 'required_if:submit,true|array|min:1',
|
||||
'steps.*.type' => "required_with:steps|string|in:{$stepTypes}",
|
||||
'steps.*.user_id' => 'required_with:steps|integer|exists:users,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'form_id.required' => __('validation.required', ['attribute' => '결재양식']),
|
||||
'form_id.exists' => __('validation.exists', ['attribute' => '결재양식']),
|
||||
'title.required' => __('validation.required', ['attribute' => '제목']),
|
||||
'content.required' => __('validation.required', ['attribute' => '내용']),
|
||||
'steps.required_if' => __('error.approval.steps_required'),
|
||||
'steps.min' => __('validation.min.array', ['attribute' => '결재단계', 'min' => 1]),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Http/Requests/Approval/SubmitRequest.php
Normal file
37
app/Http/Requests/Approval/SubmitRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use App\Models\Tenants\ApprovalLine;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SubmitRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
$stepTypes = implode(',', ApprovalLine::STEP_TYPES);
|
||||
|
||||
return [
|
||||
'steps' => 'required|array|min:1',
|
||||
'steps.*.type' => "required|string|in:{$stepTypes}",
|
||||
'steps.*.user_id' => 'required|integer|exists:users,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'steps.required' => __('error.approval.steps_required'),
|
||||
'steps.min' => __('validation.min.array', ['attribute' => '결재단계', 'min' => 1]),
|
||||
'steps.*.type.required' => __('validation.required', ['attribute' => '단계유형']),
|
||||
'steps.*.type.in' => __('validation.in', ['attribute' => '단계유형']),
|
||||
'steps.*.user_id.required' => __('validation.required', ['attribute' => '결재자']),
|
||||
'steps.*.user_id.exists' => __('validation.exists', ['attribute' => '결재자']),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Approval/UpdateRequest.php
Normal file
31
app/Http/Requests/Approval/UpdateRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Approval;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'form_id' => 'nullable|integer|exists:approval_forms,id',
|
||||
'title' => 'nullable|string|max:200',
|
||||
'content' => 'nullable|array',
|
||||
'attachments' => 'nullable|array',
|
||||
'attachments.*' => 'integer|exists:files,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'form_id.exists' => __('validation.exists', ['attribute' => '결재양식']),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user