From 02580926b7291379e7ac50d857694732f1b3115b Mon Sep 17 00:00:00 2001 From: kent Date: Sat, 26 Jul 2025 14:34:48 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=ED=9A=8C=EC=9B=90=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95=20(?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/V1/MemberController.php | 84 ++++++++++++------- app/Services/MemberService.php | 14 +++- 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/Api/V1/MemberController.php b/app/Http/Controllers/Api/V1/MemberController.php index f9d30ac..612dbf6 100644 --- a/app/Http/Controllers/Api/V1/MemberController.php +++ b/app/Http/Controllers/Api/V1/MemberController.php @@ -13,7 +13,7 @@ class MemberController extends Controller * @OA\Get( * path="/api/v1/member/index", * summary="회원 목록 조회", - * description="회원 목록을 조회합니다.", + * description="회원 목록을 페이징 형태로 반환합니다.", * tags={"Member"}, * security={ * {"ApiKeyAuth": {}}, @@ -38,46 +38,66 @@ class MemberController extends Controller * response=200, * description="회원 목록 조회 성공", * @OA\JsonContent( - * type="object", - * @OA\Property(property="success", type="boolean", example=true), - * @OA\Property(property="message", type="string", example="회원목록 조회 성공"), - * @OA\Property( - * property="data", - * type="object", - * @OA\Property( - * property="1", - * type="object", - * @OA\Property(property="mb_num", type="integer", example=1), - * @OA\Property(property="tn_num", type="string", example=null), - * @OA\Property(property="mb_id", type="string", example="admin"), - * @OA\Property(property="mb_name", type="string", example="권혁성"), - * @OA\Property(property="mb_phone", type="string", example="010-4820-9104"), - * @OA\Property(property="mb_mail", type="string", example="shine1324@gmail.com"), - * @OA\Property(property="email_verified_at", type="string", format="date-time", example=null), - * @OA\Property(property="mb_type", type="string", example=null), - * @OA\Property(property="mb_level", type="integer", example=1), - * @OA\Property(property="last_login", type="string", format="date-time", example=null), - * @OA\Property(property="reg_date", type="string", format="date-time", example="2025-07-16T09:28:41.000000Z"), - * @OA\Property(property="created_at", type="string", format="date-time", example=null), - * @OA\Property(property="updated_at", type="string", format="date-time", example="2025-07-16T09:30:56.000000Z") - * ) - * ) - * ) + * @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="« 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\Response(response=400, description="필수 파라미터 누락"), * @OA\Response(response=401, description="인증 실패"), * @OA\Response(response=403, description="권한 없음") + * @OA\Response(response=404, description="존재하지 않는 URI 또는 데이터") + * @OA\Response(response=405, description="허용되지 않는 메서드") + * @OA\Response(response=500, description="서버 에러") * ) */ public function index(Request $request) { try { - - $type = $request->input('type', 'default'); - $userToken = $request->input('user_token', ''); - $debug = $request->boolean('debug', false); - $result = MemberService::getMembers($userToken, $type, $debug); - + $result = MemberService::getMembers($request); return ApiResponse::success($result['data'], '회원목록 조회 성공',$result['query']); } catch (\Throwable $e) { return ApiResponse::error('회원목록 조회 실패', 500, [ diff --git a/app/Services/MemberService.php b/app/Services/MemberService.php index 645dfb8..205e515 100644 --- a/app/Services/MemberService.php +++ b/app/Services/MemberService.php @@ -5,6 +5,7 @@ use App\Helpers\ApiResponse; use App\Models\User; use Illuminate\Support\Facades\DB; +use Illuminate\Http\Request; class MemberService { @@ -12,12 +13,19 @@ class MemberService /** * 회원 조회(리스트) */ - public static function getMembers(string $userToken, bool $debug = false) + public static function getMembers($request) { - $query = new Member(); + $pageNo = $request->page ?? 1; + $pageSize = $request->size ?? 10; + + $query = User::whereHas('userTenants', function($q) { + $q->active(); + })->debug(); + $query = $query->paginate($pageSize, ['*'], 'page', $pageNo); + + return ApiResponse::response('result', $query); - return ApiResponse::response('get', $query, $debug); }