diff --git a/app/Services/TenantService.php b/app/Services/TenantService.php index 2c0b2da..6802546 100644 --- a/app/Services/TenantService.php +++ b/app/Services/TenantService.php @@ -154,6 +154,20 @@ public function generateTenantCode(string $tenantName): string */ public static function getTenants(array $params = []) { + $tenantId = $params['tenant_id'] ?? app('tenant_id'); + + if (!$tenantId) { + // 현재 사용자 기본 테넌트 조회 + $apiUser = app('api_user'); + $userTenant = UserTenant::where('user_id', $apiUser) + ->where('is_default', 1) + ->first(); + + if (!$userTenant) { + return ['error' => '활성(기본) 테넌트를 찾을 수 없습니다.', 'code' => 404]; + } + $tenantId = $userTenant->tenant_id; + } $pageNo = isset($params['page']) ? (int)$params['page'] : 1; $pageSize = isset($params['size']) ? (int)$params['size'] : 10;