fix : API - User 화면 개발

This commit is contained in:
2025-08-13 18:34:28 +09:00
parent 78e130030d
commit 5a622b4137
8 changed files with 614 additions and 255 deletions

View File

@@ -0,0 +1,73 @@
<?php
namespace App\Http\Controllers\Api\V1;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\MemberService;
use App\Helpers\ApiResponse;
class TenantController extends Controller
{
public function index(Request $request)
{
try {
$result = MemberService::getMembers($request);
return ApiResponse::success($result['data'], '회원목록 조회 성공',$result['query']);
} catch (\Throwable $e) {
return ApiResponse::error('회원목록 조회 실패', 500, [
'details' => $e->getMessage(),
]);
}
}
/**
* 나의 테넌트 전환
*/
public function switch()
{
//
}
/**
* Store a newly created resource in storage.
*/
/**
* Show the form for editing the specified resource.
*/
public function edit(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function delAdmin($userNo, Request $request)
{
return ApiResponse::handle(function () use ($userNo, $request) {
return MemberService::delAdmin($userNo);
}, '관리자 제외 성공', '관리자 제외 실패');
}
/**
* 관리자 설정
*/
public function setAdmin($userNo, Request $request)
{
return ApiResponse::handle(function () use ($userNo, $request) {
return MemberService::setAdmin($userNo);
}, '관리자 설정 성공', '관리자 설정 실패');
}
}

316
app/Swagger/v1/AdminApi.php Normal file
View File

@@ -0,0 +1,316 @@
<?php
namespace App\Swagger\v1;
/**
* @OA\Tag(name="Admin-Users", description="관리자 전용 사용자 관리")
*/
class AdminApi
{
/**
* @OA\Get(
* path="/api/v1/admin/users",
* tags={"Admin-Users"},
* summary="사용자 목록",
* description="필터/검색/페이지네이션으로 사용자 목록을 조회합니다.",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="q", in="query", description="이름/이메일 검색어", @OA\Schema(type="string")),
* @OA\Parameter(name="tenant_id", in="query", description="특정 테넌트로 필터", @OA\Schema(type="integer", example=1)),
* @OA\Parameter(name="role", in="query", description="역할 코드", @OA\Schema(type="string", example="manager")),
* @OA\Parameter(name="is_active", in="query", description="활성여부", @OA\Schema(type="boolean", example=true)),
* @OA\Parameter(ref="#/components/parameters/Page"),
* @OA\Parameter(ref="#/components/parameters/Size"),
* @OA\Response(
* response=200,
* description="조회 성공",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="status", type="string", example="success"),
* @OA\Property(property="message", type="string", example="OK"),
* @OA\Property(
* property="data",
* type="object",
* @OA\Property(property="items", type="array", @OA\Items(ref="#/components/schemas/User")),
* @OA\Property(property="meta", ref="#/components/schemas/PaginationMeta")
* )
* )
* ),
* @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\Post(
* path="/api/v1/admin/users",
* tags={"Admin-Users"},
* summary="사용자 생성",
* description="새 사용자를 생성합니다. (초기 비밀번호/역할 포함 가능)",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* type="object",
* required={"name","email","password"},
* @OA\Property(property="tenant_id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="김관리"),
* @OA\Property(property="email", type="string", example="admin@kdcorp.co.kr"),
* @OA\Property(property="password", type="string", example="Init!2345"),
* @OA\Property(property="phone", type="string", example="010-3333-4444"),
* @OA\Property(property="roles", type="array", @OA\Items(type="string"), example={"manager"})
* )
* ),
* @OA\Response(
* response=201,
* description="생성됨",
* @OA\JsonContent(
* allOf={
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/User"))
* }
* )
* ),
* @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=409, description="이메일 중복", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function store() {}
/**
* @OA\Get(
* path="/api/v1/admin/users/{id}",
* tags={"Admin-Users"},
* summary="사용자 단건 조회",
* description="ID 기준 사용자 상세",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer", example=101)),
* @OA\Response(
* response=200,
* description="조회 성공",
* @OA\JsonContent(
* allOf={@OA\Schema(ref="#/components/schemas/ApiResponse")},
* @OA\Schema(@OA\Property(property="data", ref="#/components/schemas/User"))
* )
* ),
* @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 show() {}
/**
* @OA\Put(
* path="/api/v1/admin/users/{id}",
* tags={"Admin-Users"},
* summary="사용자 수정",
* description="이름/연락처/역할/활성여부 등 변경",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property(property="name", type="string", example="김관리"),
* @OA\Property(property="phone", type="string", example="010-3333-4444"),
* @OA\Property(property="is_active", type="boolean", example=true),
* @OA\Property(property="roles", type="array", @OA\Items(type="string"), example={"manager","staff"})
* )
* ),
* @OA\Response(response=200, description="수정 성공", @OA\JsonContent(ref="#/components/schemas/ApiResponse")),
* @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 update() {}
/**
* @OA\Patch(
* path="/api/v1/admin/users/{id}/status",
* tags={"Admin-Users"},
* summary="활성/비활성 전환",
* description="is_active 토글",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @OA\RequestBody(required=true,
* @OA\JsonContent(type="object",
* required={"is_active"},
* @OA\Property(property="is_active", type="boolean", example=false)
* )
* ),
*
* @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 toggleStatus() {}
/**
* @OA\Delete(
* path="/api/v1/admin/users/{id}",
* tags={"Admin-Users"},
* summary="사용자 삭제(소프트 삭제)",
* description="deleted_at / deleted_by 기록",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @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=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 destroy() {}
/**
* @OA\Post(
* path="/api/v1/admin/users/{id}/restore",
* tags={"Admin-Users"},
* summary="삭제 복구",
* description="소프트 삭제 복구",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @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=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 restore() {}
/**
* @OA\Post(
* path="/api/v1/admin/users/{id}/roles",
* tags={"Admin-Users"},
* summary="역할 부여",
* description="사용자에게 역할 추가",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @OA\RequestBody(required=true,
* @OA\JsonContent(type="object",
* required={"roles"},
* @OA\Property(property="roles", type="array", @OA\Items(type="string"), example={"manager"})
* )
* ),
*
* @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=409, description="이메일/역할 중복 등 충돌", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function attachRoles() {}
/**
* @OA\Delete(
* path="/api/v1/admin/users/{id}/roles/{role}",
* tags={"Admin-Users"},
* summary="역할 해제",
* description="사용자에서 특정 역할 제거",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @OA\Parameter(name="role", in="path", required=true, @OA\Schema(type="string", example="manager")),
* @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=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=409, description="요청 충돌(없는 역할/이미 제거됨 등)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function detachRole() {}
/**
* @OA\Post(
* path="/api/v1/admin/users/{id}/reset-password",
* tags={"Admin-Users"},
* summary="비밀번호 초기화",
* description="임시 비밀번호 발급(또는 링크 전송)",
* security={{"ApiKeyAuth":{}},{"BearerAuth":{}}},
* @OA\Parameter(name="id", in="path", required=true, @OA\Schema(type="integer")),
* @OA\RequestBody(
* required=false,
* @OA\JsonContent(type="object",
* @OA\Property(property="temp_password", type="string", example="Temp!1234", description="미지정 시 서버에서 생성")
* )
* ),
* @OA\Response(response=200, description="초기화 성공", @OA\JsonContent(ref="#/components/schemas/ApiResponse")),
* @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=409, description="요청 충돌(정책 위반 등)", @OA\JsonContent(ref="#/components/schemas/ErrorResponse")),
* @OA\Response(response=500, description="서버 에러", @OA\JsonContent(ref="#/components/schemas/ErrorResponse"))
* )
*/
public function resetPassword() {}
}

View File

@@ -10,23 +10,25 @@
* security={
* {"ApiKeyAuth": {}},
* {"BearerAuth": {}}
* },
* },
* @OA\Response(
* response=200,
* description="API Key 인증 성공"
* ),
* @OA\Response(
* response=401,
* description="인증 실패"
* description="인증 실패",
* @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
* )
* )
*
*
* @OA\Post(
* path="/api/v1/login",
* summary="회원 토큰 정보확인",
* tags={"Auth"},
* security={{"ApiKeyAuth": {}},},
* security={
* {"ApiKeyAuth": {}}
* },
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
@@ -39,14 +41,20 @@
* response=200,
* description="로그인 성공",
* @OA\JsonContent(
* @OA\Property(property="message", type="string"),
* @OA\Property(property="user_token", type="string")
* @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_token", type="string", example="abc123xyz")
* )
* )
* ),
* @OA\Response(response=401, description="로그인 실패")
* @OA\Response(
* response=401,
* description="로그인 실패",
* @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
* )
* )
*
*
* @OA\Post(
* path="/api/v1/logout",
* summary="로그아웃 (Access 및 Token 무효화)",
@@ -55,9 +63,20 @@
* {"ApiKeyAuth": {}},
* {"BearerAuth": {}}
* },
* @OA\Response(response=200, description="로그아웃 성공"),
* @OA\Response(response=401, description="인증 실패")
* @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="null", example=null)
* )
* ),
* @OA\Response(
* response=401,
* description="인증 실패",
* @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
* )
* )
*/
class AuthApi {}
class AuthApi {}

View File

@@ -0,0 +1,105 @@
<?php
namespace App\Swagger\v1;
/**
* 전역 재사용 컴포넌트 정의만 모아둔 파일입니다.
*
* @OA\Parameter(
* parameter="Page",
* name="page",
* in="query",
* required=false,
* description="페이지 번호(1부터)",
* @OA\Schema(type="integer", minimum=1, example=1)
* )
*
* @OA\Parameter(
* parameter="Size",
* name="size",
* in="query",
* required=false,
* description="페이지 당 개수(기본 20)",
* @OA\Schema(type="integer", minimum=1, maximum=200, example=20)
* )
*
* @OA\Schema(
* schema="ApiResponse",
* type="object",
* @OA\Property(property="status", type="string", example="success"),
* @OA\Property(property="message", type="string", example="처리되었습니다."),
* @OA\Property(property="data", nullable=true)
* )
*
* @OA\Schema(
* schema="PaginationMeta",
* type="object",
* @OA\Property(property="page", type="integer", example=1),
* @OA\Property(property="size", type="integer", example=20),
* @OA\Property(property="total", type="integer", example=126),
* @OA\Property(property="last_page", type="integer", example=7)
* )
*
* @OA\Schema(
* schema="User",
* type="object",
* required={"id","name","email"},
* @OA\Property(property="id", type="integer", example=101),
* @OA\Property(property="tenant_id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="홍길동"),
* @OA\Property(property="email", type="string", example="hong@kdcorp.co.kr"),
* @OA\Property(property="phone", type="string", nullable=true, example="010-1234-5678"),
* @OA\Property(property="is_active", type="boolean", example=true),
* @OA\Property(property="roles", type="array", @OA\Items(type="string"), example={"admin","manager"}),
* @OA\Property(property="created_at", type="string", example="2025-07-20 10:22:33"),
* @OA\Property(property="updated_at", type="string", example="2025-08-01 15:00:10")
* )
*
* @OA\Schema(
* schema="LoginRequest",
* type="object",
* required={"email","password"},
* @OA\Property(property="email", type="string", example="hong@kdcorp.co.kr"),
* @OA\Property(property="password", type="string", example="secret1234!")
* )
*
* @OA\Schema(
* schema="TokenResponse",
* type="object",
* @OA\Property(property="access_token", type="string", example="eyJhbGciOi..."),
* @OA\Property(property="token_type", type="string", example="Bearer"),
* @OA\Property(property="expires_in", type="integer", example=3600)
* )
*
* @OA\Schema(
* schema="UserUpdateRequest",
* type="object",
* @OA\Property(property="name", type="string", example="홍길동"),
* @OA\Property(property="phone", type="string", example="010-1111-2222")
* )
*
* @OA\Schema(
* schema="PasswordChangeRequest",
* type="object",
* required={"current_password","new_password"},
* @OA\Property(property="current_password", type="string", example="oldPass!234"),
* @OA\Property(property="new_password", type="string", example="NewPass!234")
* )
*
* @OA\Schema(
* schema="SwitchTenantRequest",
* type="object",
* required={"tenant_id"},
* @OA\Property(property="tenant_id", type="integer", example=2, description="스위치할 테넌트 ID")
* )
*
* @OA\Schema(
* schema="ErrorResponse",
* type="object",
* description="공통 에러 응답 포맷",
* @OA\Property(property="success", type="boolean", example=false),
* @OA\Property(property="message", type="string", example="에러 메시지"),
* @OA\Property(property="data", type="string", nullable=true, example=null)
* )
*/
class CommonComponents {}

View File

@@ -2,195 +2,5 @@
namespace App\Swagger\v1;
/**
* @OA\Get(
* path="/api/v1/member/index",
* summary="회원 목록 조회",
* description="회원 목록을 페이징 형태로 반환합니다.",
* tags={"Member"},
* security={
* {"ApiKeyAuth": {}},
* {"BearerAuth": {}}
* },
* @OA\Parameter(
* name="page",
* in="query",
* required=false,
* description="페이지 번호 (기본값: 1)",
* @OA\Schema(type="integer", example=1)
* ),
* @OA\Parameter(
* name="size",
* in="query",
* required=false,
* description="페이지당 항목 수 (기본값: 20)",
* @OA\Schema(type="integer", example=20)
* ),
*
* @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="current_page", type="integer", example=1),
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="user_id", type="string", example="hamss"),
* @OA\Property(property="phone", type="string", example="010-4820-9104"),
* @OA\Property(property="options", type="string", nullable=true, example=null),
* @OA\Property(property="name", type="string", example="권혁성"),
* @OA\Property(property="email", type="string", example="shine1324@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\Property(property="first_page_url", type="string", example="http://api.sam.kr/api/v1/member/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="http://api.sam.kr/api/v1/member/index?page=1"),
* @OA\Property(
* property="links",
* type="array",
* @OA\Items(
* @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="http://api.sam.kr/api/v1/member/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\Get (
* path="/api/v1/member/show/{user_no}",
* summary="회원 상세조회",
* description="user_no 기준으로 회원 상세 정보를 조회합니다.",
* tags={"Member"},
* 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(
* @OA\Property(property="success", type="boolean", example=true),
* @OA\Property(property="message", type="string", example="회원 상세조회 성공"),
* @OA\Property(
* property="data",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="user_id", type="string", example="hamss"),
* @OA\Property(property="phone", type="string", example="010-4820-9104"),
* @OA\Property(property="options", type="string", nullable=true, example=null),
* @OA\Property(property="name", type="string", example="권혁성"),
* @OA\Property(property="email", type="string", example="shine1324@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\Response(response=401, description="인증 실패"),
* @OA\Response(response=404, description="회원 정보 없음"),
* )
*
* @OA\Get(
* path="/api/v1/member/me",
* summary="내 정보 조회",
* description="내정보와 테넌트 정보를 전달 합니다.",
* tags={"Member"},
* security={
* {"ApiKeyAuth":{}},
* {"BearerAuth":{}}
* },
* @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=3),
* @OA\Property(property="user_id", type="string", example="test"),
* @OA\Property(property="phone", type="string", example="010-1234-5678"),
* @OA\Property(property="options", type="string", nullable=true, example=null),
* @OA\Property(property="name", type="string", example="테스트"),
* @OA\Property(property="email", type="string", example="test@5130.co.kr"),
* @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-17 13:19:37"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2025-07-26 15:51:14"),
* @OA\Property(property="deleted_at", type="string", format="date-time", nullable=true, example=null)
* ),
* @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="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\Response(
* response=401,
* description="인증 실패 (헤더 누락, 유효하지 않은 토큰/키 등)"
* )
* )
*/
class MemberApi {}

View File

@@ -3,45 +3,60 @@
namespace App\Swagger\v1;
/**
* @OA\Get (
* 제품 카테고리 스키마
* @OA\Schema(
* schema="ProductCategory",
* type="object",
* description="제품 카테고리",
* required={"id","code_group","code","name","is_active","sort_order"},
* @OA\Property(property="id", type="integer", example=4),
* @OA\Property(property="code_group", type="string", example="category"),
* @OA\Property(property="code", type="string", example="BP"),
* @OA\Property(property="name", type="string", example="절곡판"),
* @OA\Property(property="parent_id", type="integer", nullable=true, example=null),
* @OA\Property(
* property="attributes",
* type="object",
* nullable=true,
* description="카테고리 속성(자유형식 JSON)",
* example={"color":"blue","flags":{"screen":true}}
* ),
* @OA\Property(property="description", type="string", nullable=true, example="절곡판"),
* @OA\Property(property="is_active", type="integer", example=1),
* @OA\Property(property="sort_order", type="integer", example=10),
* @OA\Property(property="created_at", type="string", format="date-time", example="2025-07-23T09:00:00+09:00"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2025-07-23T09:00:00+09:00")
* )
*
* 카테고리 목록 조회
* @OA\Get(
* path="/api/v1/product/category",
* summary="제품 카테고리 목록 조회",
* description="제품 카테고리(최상위, parent_id=null) 리스트를 반환합니다.",
* description="제품 카테고리(최상위: parent_id = null) 리스트를 반환합니다.",
* tags={"Product"},
* security={
* {"ApiKeyAuth": {}},
* {"BearerAuth": {}}
* },
* security={{"ApiKeyAuth": {}},{"BearerAuth": {}}},
* @OA\Response(
* response=200,
* description="카테고리 목록 조회 성공",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="status", type="string", example="success"),
* @OA\Property(property="message", type="string", example="get 성공"),
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(
* type="object",
* @OA\Property(property="id", type="integer", example=4),
* @OA\Property(property="code_group", type="string", example="category"),
* @OA\Property(property="code", type="string", example="BP"),
* @OA\Property(property="name", type="string", example="절곡판"),
* @OA\Property(property="parent_id", type="integer", example=null),
* @OA\Property(property="attributes", type="string", example="[{...}]"),
* @OA\Property(property="description", type="string", example="절곡판"),
* @OA\Property(property="is_active", type="integer", example=1),
* @OA\Property(property="sort_order", type="integer", example=10),
* @OA\Property(property="created_at", type="string", format="date-time", example="2025-07-23T09:00:00Z"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2025-07-23T09:00:00Z")
* allOf={
* @OA\Schema(ref="#/components/schemas/ApiResponse"),
* @OA\Schema(
* @OA\Property(
* property="data",
* type="array",
* @OA\Items(ref="#/components/schemas/ProductCategory")
* )
* )
* )
* }
* )
* ),
* @OA\Response(response=401, description="인증 실패"),
* @OA\Response(response=500, description="서버 에러")
* @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"))
* )
*/
class ProductApi {}
class ProductApi {}

View File

@@ -6,7 +6,7 @@
* @OA\Info(
* version="1.0.0",
* title="SAM API Documentation",
* description="===============================<br><strong>[공통 에러 응답 포맷]</strong><br>400: 필수 파라미터 누락<br>401: 인증 실패<br>403: 권한 없음<br>404: 존재하지 않는 URI 또는 데이터<br>405: 허용되지 않는 메서드<br>500: 서버 에러<br><br><strong>모든 에러 응답 예시:</strong><br>{<br>&nbsp;&nbsp;&quot;success&quot;: false,<br>&nbsp;&nbsp;&quot;message&quot;: &quot;에러 메시지&quot;,<br>&nbsp;&nbsp;&quot;data&quot;: null<br>}<br>===============================",
* description="===============================<br><strong>[공통 에러 응답 포맷]</strong><br>400: 필수 파라미터 누락<br>401: 인증 실패<br>403: 권한 없음<br>404: 존재하지 않는 URI 또는 데이터<br>405: 허용되지 않는 메서드<br>500: 서버 에러<br><br><strong>모든 에러 응답 예시:</strong><br>{<br>&nbsp;&nbsp;&quot;success&quot;: false,<br>&nbsp;&nbsp;&quot;message&quot;: &quot;에러 메시지&quot;,<br>&nbsp;&nbsp;&quot;data&quot;: null<br>}<br>===============================",
* @OA\Contact(
* email="shine1324@gmail.com"
* )
@@ -22,13 +22,38 @@
* type="apiKey",
* in="header",
* name="X-API-KEY"
* )
* )
*
* @OA\SecurityScheme(
* securityScheme="BearerAuth",
* type="http",
* scheme="bearer",
* bearerFormat="JWT"
* )
* )
*
* @OA\Tag(
* name="Auth",
* description="로그인/로그아웃 및 인증 관련 API"
* )
* @OA\Tag(
* name="API Key 인증",
* description="API Key 유효성 검사"
* )
* @OA\Tag(
* name="User",
* description="사용자 자기 계정 관련 API"
* )
* @OA\Tag(
* name="Member",
* description="회원 관리 API"
* )
* @OA\Tag(
* name="Admin-Users",
* description="관리자 사용자 관리 API"
* )
* @OA\Tag(
* name="Product",
* description="제품 관련 API"
* )
*/
class SAMInfo {}

View File

@@ -4,14 +4,12 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\V1\CommonController;
use App\Http\Controllers\Api\V1\ApiController;
use App\Http\Controllers\Api\V1\MemberController;
use App\Http\Controllers\Api\V1\AdminApiController;
use App\Http\Controllers\Api\V1\FileController;
use App\Http\Controllers\Api\V1\ProductController;
use App\Http\Controllers\Api\V1\MaterialController;
use App\Http\Controllers\Api\V1\ModelController;
use App\Http\Controllers\Api\V1\BomController;
use App\Http\Controllers\Api\V1\TenantController;
use App\Http\Controllers\Api\V1\UserController;
// error test
@@ -60,10 +58,8 @@
Route::put('me/password', [UserController::class, 'changePassword'])->name('v1.users.me.password'); // 비밀번호 변겅
Route::get('me/tenants', [UserController::class, 'tenants'])->name('v1.users.me.tenants.index'); // 내 테넌트 목록
Route::patch('me/tenants/switch',[UserController::class, 'switchTenant'])->name('v1.users.me.tenants.switch'); // 활성 테넌트 전환
Route::patch('me/tenants/switch', [UserController::class, 'switchTenant'])->name('v1.users.me.tenants.switch'); // 활성 테넌트 전환
});
});
// File API
Route::prefix('file')->group(function () {
@@ -71,6 +67,7 @@
Route::get('list', [FileController::class, 'list'])->name('v1.file.list'); // 파일 목록 조회
Route::delete('delete', [FileController::class, 'delete'])->name('v1.file.delete'); // 파일 삭제
Route::get('info', [FileController::class, 'findFile'])->name('v1.file.info'); // 파일 정보 조회
});
// Material, Model, BOM API
@@ -82,7 +79,6 @@
});
// ─────────────────────────────────────────────────────────────
// 공통 미들웨어 메모:
// - 'apikey' : X-API-KEY 검사 미들웨어 (커스텀)
@@ -109,7 +105,7 @@
// Auth (User)
Route::prefix('auth')->group(function () {
Route::post('login', [\App\Http\Controllers\Api\V1\AuthController::class, 'login'])
Route::post('login', [\App\Http\Controllers\Api\V1\AuthController::class, 'login'])
->name('v1.auth.login'); // Bearer 불필요(로그인)
Route::post('logout', [\App\Http\Controllers\Api\V1\AuthController::class, 'logout'])
@@ -119,12 +115,12 @@
// Users (me)
Route::prefix('users')->middleware('auth:sanctum')->group(function () {
Route::get('me', [\App\Http\Controllers\Api\V1\User\MeController::class, 'show'])->name('v1.users.me.show');
Route::put('me', [\App\Http\Controllers\Api\V1\User\MeController::class, 'update'])->name('v1.users.me.update');
Route::put('me/password', [\App\Http\Controllers\Api\V1\User\MeController::class, 'changePassword'])->name('v1.users.me.password');
Route::get('me', [\App\Http\Controllers\Api\V1\User\MeController::class, 'show'])->name('v1.users.me.show');
Route::put('me', [\App\Http\Controllers\Api\V1\User\MeController::class, 'update'])->name('v1.users.me.update');
Route::put('me/password', [\App\Http\Controllers\Api\V1\User\MeController::class, 'changePassword'])->name('v1.users.me.password');
Route::get('me/tenants', [\App\Http\Controllers\Api\V1\User\TenantController::class, 'index'])->name('v1.users.me.tenants.index');
Route::patch('me/tenants/switch',[\App\Http\Controllers\Api\V1\User\TenantController::class, 'switch'])->name('v1.users.me.tenants.switch');
Route::get('me/tenants', [\App\Http\Controllers\Api\V1\User\TenantController::class, 'index'])->name('v1.users.me.tenants.index');
Route::patch('me/tenants/switch', [\App\Http\Controllers\Api\V1\User\TenantController::class, 'switch'])->name('v1.users.me.tenants.switch');
});
});
@@ -150,13 +146,13 @@
->group(function () {
// 목록/생성
Route::get('users', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'index'])->name('v1.admin.users.index');
Route::post('users', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'store'])->name('v1.admin.users.store');
Route::get('users', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'index'])->name('v1.admin.users.index');
Route::post('users', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'store'])->name('v1.admin.users.store');
// 단건
Route::get('users/{id}', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'show'])->name('v1.admin.users.show');
Route::put('users/{id}', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'update'])->name('v1.admin.users.update');
Route::delete('users/{id}',[\App\Http\Controllers\Api\V1\Admin\UserController::class, 'destroy'])->name('v1.admin.users.destroy');
Route::get('users/{id}', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'show'])->name('v1.admin.users.show');
Route::put('users/{id}', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'update'])->name('v1.admin.users.update');
Route::delete('users/{id}', [\App\Http\Controllers\Api\V1\Admin\UserController::class, 'destroy'])->name('v1.admin.users.destroy');
// 상태 토글
Route::patch('users/{id}/status', [\App\Http\Controllers\Api\V1\Admin\UserStatusController::class, 'toggle'])->name('v1.admin.users.status.toggle');
@@ -165,8 +161,8 @@
Route::post('users/{id}/restore', [\App\Http\Controllers\Api\V1\Admin\UserRestoreController::class, 'restore'])->name('v1.admin.users.restore');
// 역할 부여/해제
Route::post('users/{id}/roles', [\App\Http\Controllers\Api\V1\Admin\UserRoleController::class, 'attach'])->name('v1.admin.users.roles.attach');
Route::delete('users/{id}/roles/{role}', [\App\Http\Controllers\Api\V1\Admin\UserRoleController::class, 'detach'])->name('v1.admin.users.roles.detach');
Route::post('users/{id}/roles', [\App\Http\Controllers\Api\V1\Admin\UserRoleController::class, 'attach'])->name('v1.admin.users.roles.attach');
Route::delete('users/{id}/roles/{role}', [\App\Http\Controllers\Api\V1\Admin\UserRoleController::class, 'detach'])->name('v1.admin.users.roles.detach');
// 비밀번호 초기화
Route::post('users/{id}/reset-password', [\App\Http\Controllers\Api\V1\Admin\UserPasswordController::class, 'reset'])->name('v1.admin.users.password.reset');