ソースを参照

修复URS Request类继承和配置获取问题

- 修复UrsGetUserLevelCountRequest和UrsGetUserTeamRequest继承错误的BaseRequest类
- 统一使用getUrsCredential()和getService()方法获取配置
- 参考UrsGetUserInfoRequest的正确实现方式
- 移除错误的构造函数,使用基类的构造函数
- 确保所有URS Request类使用一致的配置获取方式
notfff 6 ヶ月 前
コミット
d840dd1074

+ 7 - 14
ThirdParty/Urs/Request/UrsGetUserLevelCountRequest.php

@@ -2,7 +2,6 @@
 
 
 namespace ThirdParty\Urs\Request;
 namespace ThirdParty\Urs\Request;
 
 
-use App\Module\ThirdParty\Services\BaseRequest;
 use ThirdParty\Urs\Util\CryptoService;
 use ThirdParty\Urs\Util\CryptoService;
 
 
 /**
 /**
@@ -13,14 +12,7 @@ use ThirdParty\Urs\Util\CryptoService;
  */
  */
 class UrsGetUserLevelCountRequest extends BaseRequest
 class UrsGetUserLevelCountRequest extends BaseRequest
 {
 {
-    /**
-     * 构造函数
-     */
-    public function __construct()
-    {
-        // 使用'urs'作为服务代码,需要在thirdparty_services表中注册
-        parent::__construct('urs');
-    }
+
 
 
     /**
     /**
      * 处理获取用户下级统计请求
      * 处理获取用户下级统计请求
@@ -41,10 +33,11 @@ class UrsGetUserLevelCountRequest extends BaseRequest
         }
         }
 
 
         // 获取URS配置
         // 获取URS配置
-        $config = $this->getConfig();
-        $apiUrl = $config['api_url'] ?? '';
-        $appKey = $config['app_key'] ?? '';
-        $ecologyId = $config['ecology_id'] ?? 1;
+        $c = $this->getUrsCredential();
+
+        $apiUrl = $this->getService()->base_url; // 直接使用服务的base_url
+        $appKey = $c->getApiKey();
+        $ecologyId = $c->getEcologyId(); // 修复:应该获取ecologyId而不是apiKey
 
 
         if (empty($apiUrl) || empty($appKey)) {
         if (empty($apiUrl) || empty($appKey)) {
             throw new \Exception('URS配置不完整,缺少api_url或app_key');
             throw new \Exception('URS配置不完整,缺少api_url或app_key');
@@ -69,7 +62,7 @@ class UrsGetUserLevelCountRequest extends BaseRequest
         // 解密响应数据
         // 解密响应数据
         if (isset($response['data'], $response['iv'], $response['timestamp'], $response['sign'])) {
         if (isset($response['data'], $response['iv'], $response['timestamp'], $response['sign'])) {
             $decryptedResponse = $cryptoService->decrypt($response);
             $decryptedResponse = $cryptoService->decrypt($response);
-            
+
             return [
             return [
                 'success' => true,
                 'success' => true,
                 'message' => '获取用户下级统计成功',
                 'message' => '获取用户下级统计成功',

+ 7 - 14
ThirdParty/Urs/Request/UrsGetUserTeamRequest.php

@@ -2,7 +2,6 @@
 
 
 namespace ThirdParty\Urs\Request;
 namespace ThirdParty\Urs\Request;
 
 
-use App\Module\ThirdParty\Services\BaseRequest;
 use ThirdParty\Urs\Util\CryptoService;
 use ThirdParty\Urs\Util\CryptoService;
 
 
 /**
 /**
@@ -13,14 +12,7 @@ use ThirdParty\Urs\Util\CryptoService;
  */
  */
 class UrsGetUserTeamRequest extends BaseRequest
 class UrsGetUserTeamRequest extends BaseRequest
 {
 {
-    /**
-     * 构造函数
-     */
-    public function __construct()
-    {
-        // 使用'urs'作为服务代码,需要在thirdparty_services表中注册
-        parent::__construct('urs');
-    }
+
 
 
     /**
     /**
      * 处理获取用户团队关系请求
      * 处理获取用户团队关系请求
@@ -37,10 +29,11 @@ class UrsGetUserTeamRequest extends BaseRequest
         }
         }
 
 
         // 获取URS配置
         // 获取URS配置
-        $config = $this->getConfig();
-        $apiUrl = $config['api_url'] ?? '';
-        $appKey = $config['app_key'] ?? '';
-        $ecologyId = $config['ecology_id'] ?? 1;
+        $c = $this->getUrsCredential();
+
+        $apiUrl = $this->getService()->base_url; // 直接使用服务的base_url
+        $appKey = $c->getApiKey();
+        $ecologyId = $c->getEcologyId(); // 修复:应该获取ecologyId而不是apiKey
 
 
         if (empty($apiUrl) || empty($appKey)) {
         if (empty($apiUrl) || empty($appKey)) {
             throw new \Exception('URS配置不完整,缺少api_url或app_key');
             throw new \Exception('URS配置不完整,缺少api_url或app_key');
@@ -64,7 +57,7 @@ class UrsGetUserTeamRequest extends BaseRequest
         // 解密响应数据
         // 解密响应数据
         if (isset($response['data'], $response['iv'], $response['timestamp'], $response['sign'])) {
         if (isset($response['data'], $response['iv'], $response['timestamp'], $response['sign'])) {
             $decryptedResponse = $cryptoService->decrypt($response);
             $decryptedResponse = $cryptoService->decrypt($response);
-            
+
             return [
             return [
                 'success' => true,
                 'success' => true,
                 'message' => '获取用户团队关系成功',
                 'message' => '获取用户团队关系成功',