Files
sam-api/app/Swagger/v1/RegisterApi.php
hskwon 48e76432ee 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
2025-11-06 17:24:42 +09:00

120 lines
5.8 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Post(
* path="/api/v1/register",
* tags={"Auth"},
* summary="회원가입 및 테넌트 생성",
* description="신규 회원가입과 동시에 새로운 테넌트(회사)를 생성합니다. 사용자는 자동으로 system_manager 역할이 부여되며 모든 테넌트 메뉴 권한을 갖습니다.",
* operationId="register",
*
* @OA\RequestBody(
* required=true,
* description="회원가입 정보",
*
* @OA\JsonContent(
* required={"user_id", "name", "email", "password", "password_confirmation", "company_name", "business_num"},
*
* @OA\Property(property="user_id", type="string", example="john_doe", description="사용자 아이디 (영문, 숫자, _, - 만 허용)"),
* @OA\Property(property="name", type="string", example="홍길동", description="사용자 이름"),
* @OA\Property(property="email", type="string", format="email", example="john@example.com", description="이메일 주소"),
* @OA\Property(property="phone", type="string", example="010-1234-5678", description="전화번호 (선택)", nullable=true),
* @OA\Property(property="password", type="string", format="password", example="password123!", description="비밀번호 (최소 8자)"),
* @OA\Property(property="password_confirmation", type="string", format="password", example="password123!", description="비밀번호 확인"),
* @OA\Property(property="position", type="string", example="개발팀장", description="직책 (선택)", nullable=true),
* @OA\Property(property="company_name", type="string", example="(주)테크컴퍼니", description="회사명"),
* @OA\Property(property="business_num", type="string", example="123-45-67890", description="사업자등록번호 (000-00-00000 형식)"),
* @OA\Property(property="company_scale", type="string", example="중소기업", description="회사 규모 (선택)", nullable=true),
* @OA\Property(property="industry", type="string", example="IT/소프트웨어", description="업종 (선택)", nullable=true)
* )
* ),
*
* @OA\Response(
* response=200,
* description="회원가입 성공",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="회원가입이 완료되었습니다"),
* @OA\Property(
* property="data",
* type="object",
* @OA\Property(
* property="user",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="user_id", type="string", example="john_doe"),
* @OA\Property(property="name", type="string", example="홍길동"),
* @OA\Property(property="email", type="string", example="john@example.com"),
* @OA\Property(property="phone", type="string", example="010-1234-5678", nullable=true),
* @OA\Property(
* property="options",
* type="object",
* @OA\Property(property="position", type="string", example="개발팀장"),
* nullable=true
* )
* ),
* @OA\Property(
* property="tenant",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="company_name", type="string", example="(주)테크컴퍼니"),
* @OA\Property(property="business_num", type="string", example="123-45-67890"),
* @OA\Property(property="tenant_st_code", type="string", example="trial", description="테넌트 상태 (trial: 데모, active: 정식, none: 비활성)"),
* @OA\Property(
* property="options",
* type="object",
* @OA\Property(property="company_scale", type="string", example="중소기업"),
* @OA\Property(property="industry", type="string", example="IT/소프트웨어"),
* nullable=true
* )
* )
* )
* )
* ),
*
* @OA\Response(
* response=422,
* description="유효성 검증 실패",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=false),
* @OA\Property(property="message", type="string", example="유효성 검증에 실패했습니다"),
* @OA\Property(
* property="errors",
* type="object",
* @OA\Property(
* property="user_id",
* type="array",
*
* @OA\Items(type="string", example="이미 사용 중인 아이디입니다")
* ),
*
* @OA\Property(
* property="business_num",
* type="array",
*
* @OA\Items(type="string", example="사업자등록번호 형식이 올바르지 않습니다 (000-00-00000)")
* )
* )
* )
* ),
*
* @OA\Response(
* response=500,
* description="서버 오류",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=false),
* @OA\Property(property="message", type="string", example="회원가입 처리 중 오류가 발생했습니다")
* )
* )
* )
*/
class RegisterApi {}