fix : 회원 목록 조회 수정 (페이지네이션 추가)
This commit is contained in:
@@ -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, [
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user