Files
sam-api/app/Swagger/v1/UserApi.php
hskwon 97c0d8245e feat: UserApi.php Swagger 점검 및 개선 (Phase 3-4)
- UserUpdateRequest.php 생성 (검증 로직 분리)
- PasswordChangeRequest.php 생성 (비밀번호 변경 검증)
- SwitchTenantRequest.php 생성 (테넌트 전환 검증)
- UserApi.php에 Request 스키마 추가
- UserController.php FormRequest 적용 및 DI 패턴 적용
- MemberService static 호출 → DI 인스턴스 호출
- lang/ko/message.php user 메시지 키 추가
- SAM API Development Rules 준수 완료
2025-11-07 02:44:11 +09:00

374 lines
17 KiB
PHP

<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Auth", description="로그인/로그아웃")
* @OA\Tag(name="User", description="사용자 본인 정보/비밀번호 변경 등")
*/
/**
* @OA\Schema(
* schema="Member",
* type="object",
* description="회원 기본 정보",
* required={"id","user_id","name","email"},
*
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="user_id", type="string", example="hamss"),
* @OA\Property(property="phone", type="string", nullable=true, example="010-4820-9104"),
* @OA\Property(property="options", type="string", nullable=true, example=null),
* @OA\Property(property="name", type="string", example="Kent"),
* @OA\Property(property="email", type="string", example="codebridge@gmail.com"),
* @OA\Property(property="email_verified_at", type="string", format="date-time", nullable=true, example=null),
* @OA\Property(property="last_login_at", type="string", format="date-time", nullable=true, example=null),
* @OA\Property(property="current_team_id", type="integer", nullable=true, example=null),
* @OA\Property(property="profile_photo_path", type="string", nullable=true, example=null),
* @OA\Property(property="created_at", type="string", format="date-time", example="2025-07-16 18:28:41"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2025-07-25 23:13:06"),
* @OA\Property(property="deleted_at", type="string", format="date-time", nullable=true, example=null)
* )
*
* @OA\Schema(
* schema="MemberPagination",
* type="object",
* description="라라벨 LengthAwarePaginator 기본 구조",
*
* @OA\Property(property="current_page", type="integer", example=1),
* @OA\Property(
* property="data",
* type="array",
*
* @OA\Items(ref="#/components/schemas/Member")
* ),
*
* @OA\Property(property="first_page_url", type="string", example="/api/v1/users/index?page=1"),
* @OA\Property(property="from", type="integer", example=1),
* @OA\Property(property="last_page", type="integer", example=1),
* @OA\Property(property="last_page_url", type="string", example="/api/v1/users/index?page=1"),
* @OA\Property(
* property="links",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(property="url", type="string", nullable=true, example=null),
* @OA\Property(property="label", type="string", example="&laquo; Previous"),
* @OA\Property(property="active", type="boolean", example=false)
* )
* ),
* @OA\Property(property="next_page_url", type="string", nullable=true, example=null),
* @OA\Property(property="path", type="string", example="/api/v1/users/index"),
* @OA\Property(property="per_page", type="integer", example=20),
* @OA\Property(property="prev_page_url", type="string", nullable=true, example=null),
* @OA\Property(property="to", type="integer", example=3),
* @OA\Property(property="total", type="integer", example=3)
* )
*
* @OA\Schema(
* schema="TenantBrief",
* type="object",
* description="간단 테넌트 정보",
* required={"id","company_name"},
*
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="company_name", type="string", example="(주)경동기업"),
* @OA\Property(property="code", type="string", example="KDCOM"),
* @OA\Property(property="email", type="string", example="kd5130@naver.com"),
* @OA\Property(property="phone", type="string", example="01083935130"),
* @OA\Property(property="address", type="string", example="경기도 김포시 통진읍 옹정로 45-22"),
* @OA\Property(property="business_num", type="string", example="1398700333"),
* @OA\Property(property="corp_reg_no", type="string", nullable=true, example=null),
* @OA\Property(property="ceo_name", type="string", example="이대표"),
* @OA\Property(property="homepage", type="string", nullable=true, example=null),
* @OA\Property(property="fax", type="string", nullable=true, example=null),
* @OA\Property(property="logo", type="string", nullable=true, example=null),
* @OA\Property(property="admin_memo", type="string", nullable=true, example=null),
* @OA\Property(property="options", type="string", nullable=true, example=null)
* )
*
* @OA\Schema(
* schema="MeResponseData",
* type="object",
* description="내 정보 + 테넌트 정보",
*
* @OA\Property(property="user", ref="#/components/schemas/Member"),
* @OA\Property(property="tenant", ref="#/components/schemas/TenantBrief")
* )
*
* @OA\Schema(
* schema="UserUpdateRequest",
* type="object",
* description="사용자 정보 수정 요청",
*
* @OA\Property(property="name", type="string", maxLength=100, example="홍길동"),
* @OA\Property(property="phone", type="string", nullable=true, maxLength=20, example="010-1234-5678"),
* @OA\Property(property="email", type="string", maxLength=100, example="user@example.com")
* )
*
* @OA\Schema(
* schema="PasswordChangeRequest",
* type="object",
* required={"current_password","new_password","new_password_confirmation"},
* description="비밀번호 변경 요청",
*
* @OA\Property(property="current_password", type="string", format="password", example="current123"),
* @OA\Property(property="new_password", type="string", format="password", minLength=8, example="newpass123"),
* @OA\Property(property="new_password_confirmation", type="string", format="password", example="newpass123")
* )
*
* @OA\Schema(
* schema="SwitchTenantRequest",
* type="object",
* required={"tenant_id"},
* description="테넌트 전환 요청",
*
* @OA\Property(property="tenant_id", type="integer", example=2)
* )
*/
class UserApi
{
/**
* @OA\Get(
* path="/api/v1/users/me",
* summary="내 정보 조회",
* description="내 정보와 활성 테넌트 정보를 반환합니다.",
* tags={"User"},
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
*
* @OA\Response(
* response=200,
* description="나의 정보 조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/MeResponseData"))
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패 (헤더 누락, 유효하지 않은 토큰/키 등)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function me() {}
/**
* @OA\Put(
* path="/api/v1/users/me",
* tags={"User"},
* summary="내 정보 수정",
* description="이름/연락처 등 프로필 정보를 수정합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/UserUpdateRequest")),
*
* @OA\Response(
* response=200,
* description="수정 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Member"))
* }
* )
* ),
*
* @OA\Response(response=400, description="필수 파라미터 누락", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="존재하지 않는 URI 또는 데이터", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function updateMe() {}
/**
* @OA\Put(
* path="/api/v1/users/me/password",
* tags={"User"},
* summary="비밀번호 변경",
* description="현재 비밀번호 검증 후 새 비밀번호로 변경합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/PasswordChangeRequest")),
*
* @OA\Response(
* response=204,
* description="변경 성공(콘텐츠 없음)",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="변경 성공"),
* @OA\Property(property="data", type="object", nullable=true, example=null)
* )
* ),
*
* @OA\Response(response=400, description="필수 파라미터 누락", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function changePassword() {}
/**
* @OA\Get(
* path="/api/v1/users/me/tenants",
* tags={"User"},
* summary="내 테넌트 목록",
* description="사용자가 소속된 테넌트 목록을 반환합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\Response(
* response=200,
* description="조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(
* property="data",
* type="array",
*
* @OA\Items(type="object",
*
* @OA\Property(property="tenant_id", type="integer", example=1),
* @OA\Property(property="tenant_name", type="string", example="경동기업"),
* @OA\Property(property="is_active", type="boolean", example=true)
* )
* )
* )
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="존재하지 않는 URI 또는 데이터", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function myTenants() {}
/**
* @OA\Patch(
* path="/api/v1/users/me/tenants/switch",
* tags={"User"},
* summary="활성 테넌트 전환",
* description="현재 세션/토큰의 활성 테넌트를 전환합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
*
* @OA\RequestBody(required=true, @OA\JsonContent(ref="#/components/schemas/SwitchTenantRequest")),
*
* @OA\Response(
* response=204,
* description="전환 성공(콘텐츠 없음)",
*
* @OA\JsonContent(
*
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="변경 성공"),
* @OA\Property(property="data", type="object", nullable=true, example=null)
* )
* ),
*
* @OA\Response(response=400, description="필수 파라미터 누락", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="존재하지 않는 URI 또는 데이터", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function switchTenant() {}
/**
* @OA\Get(
* path="/api/v1/users/index",
* summary="회원 목록 조회",
* description="회원 목록을 페이징 형태로 반환합니다.",
* tags={"User"},
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
*
* @OA\Parameter(ref="#/components/parameters/Page"),
* @OA\Parameter(ref="#/components/parameters/Size"),
*
* @OA\Response(
* response=200,
* description="회원 목록 조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
*
* @OA\Property(property="data", ref="#/components/schemas/MemberPagination")
* )
* }
* )
* ),
*
* @OA\Response(response=400, description="필수 파라미터 누락", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=403, description="권한 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="존재하지 않는 URI 또는 데이터", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function index() {}
/**
* @OA\Get(
* path="/api/v1/users/show/{user_no}",
* summary="회원 상세조회",
* description="user_no 기준으로 회원 상세 정보를 조회합니다.",
* tags={"User"},
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
*
* @OA\Parameter(
* name="user_no",
* in="path",
* required=true,
* description="회원 번호 (USER_NO)",
*
* @OA\Schema(type="integer", example=1)
* ),
*
* @OA\Response(
* response=200,
* description="회원 상세조회 성공",
*
* @OA\JsonContent(
* allOf={
*
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/Member"))
* }
* )
* ),
*
* @OA\Response(response=401, description="인증 실패", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=404, description="회원 정보 없음", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=405, description="허용되지 않는 메서드", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function show() {}
}