feat: 회원가입 + 테넌트 생성 통합 API 추가 (/api/v1/register)
- 사용자 등록 + 테넌트 생성 + 시스템 관리자 권한 자동 부여 - 사업자번호 조건부 검증 (active 테넌트만 unique) - 글로벌 메뉴 자동 복제 (parent_id 매핑 알고리즘) - DB 트랜잭션으로 전체 프로세스 원자성 보장 추가: - RegisterRequest: FormRequest 검증 (conditional unique) - RegisterService: 9-step 통합 비즈니스 로직 - RegisterController: ApiResponse::handle() 패턴 - RegisterApi: 완전한 Swagger 문서 수정: - MenusStep: 글로벌 메뉴 복제 로직 구현 - message.php: 'registered' 키 추가 - error.php: 4개 에러 메시지 추가 - routes/api.php: POST /api/v1/register 라우트 SAM API Rules 준수: - Service-First, FormRequest, i18n, Swagger, DB Transaction
This commit is contained in:
97
app/Http/Requests/RegisterRequest.php
Normal file
97
app/Http/Requests/RegisterRequest.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class RegisterRequest 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 [
|
||||
// User fields
|
||||
'user_id' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'regex:/^[a-zA-Z0-9_-]+$/',
|
||||
'unique:users,user_id',
|
||||
],
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => [
|
||||
'required',
|
||||
'string',
|
||||
'email',
|
||||
'max:255',
|
||||
'unique:users,email',
|
||||
],
|
||||
'phone' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'max:20',
|
||||
'regex:/^[0-9-]+$/',
|
||||
],
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
'position' => 'nullable|string|max:100',
|
||||
|
||||
// Tenant fields
|
||||
'company_name' => 'required|string|max:255',
|
||||
'business_num' => [
|
||||
'required',
|
||||
'string',
|
||||
'regex:/^\d{3}-\d{2}-\d{5}$/',
|
||||
Rule::unique('tenants', 'business_num')->where(function ($query) {
|
||||
return $query->where('tenant_st_code', 'active');
|
||||
}),
|
||||
],
|
||||
'company_scale' => 'nullable|string|max:50',
|
||||
'industry' => 'nullable|string|max:100',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => __('validation.attributes.user_id'),
|
||||
'name' => __('validation.attributes.name'),
|
||||
'email' => __('validation.attributes.email'),
|
||||
'phone' => __('validation.attributes.phone'),
|
||||
'password' => __('validation.attributes.password'),
|
||||
'position' => __('validation.attributes.position'),
|
||||
'company_name' => __('validation.attributes.company_name'),
|
||||
'business_num' => __('validation.attributes.business_num'),
|
||||
'company_scale' => __('validation.attributes.company_scale'),
|
||||
'industry' => __('validation.attributes.industry'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'business_num.regex' => __('error.business_num_format'),
|
||||
'business_num.unique' => __('error.business_num_duplicate_active'),
|
||||
'user_id.regex' => __('error.user_id_format'),
|
||||
'phone.regex' => __('error.phone_format'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user