Files
sam-api/app/Swagger/v1/UserApi.php
hskwon c5ea6d189a feat: Swagger 문서 전면 수정 및 ClientGroup 자동 복원 기능 추가
- CommonComponents.php: ApiResponse/ErrorResponse 글로벌 스키마 수정
  - property="status" → property="success" (boolean)
  - property="data" → property="error" (object with code/details)

- AuthApi, AdminApi, UserApi: 개별 응답 스키마 수정
  - signup(): allOf 구조로 변경
  - index(): Laravel LengthAwarePaginator 구조 적용
  - updateMe(): Member schema 참조로 변경

- PermissionApi, MaterialApi, DepartmentApi: 로컬 스키마 재정의 제거

- ClientGroupService: 삭제된 데이터 자동 복원 기능 구현
  - store(): withTrashed()로 삭제된 데이터 확인 후 restore()
  - update(): 삭제된 코드 존재 시 에러 반환

- ClientApi: client_group_id 필드 추가
  - Client, ClientCreateRequest, ClientUpdateRequest 스키마에 추가

- lang/ko/error.php, lang/en/error.php: 에러 메시지 추가
  - duplicate_code, has_clients, code_exists_in_deleted

- Swagger 문서 재생성 및 검증 완료
2025-10-14 09:10:52 +09:00

301 lines
16 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")
* )
*/
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() {}
}