From e03505135d9816c8b6ea67a91a7e1f493e662b6f Mon Sep 17 00:00:00 2001
From: houzhongjian <houzhongyi@126.com>
Date: 星期三, 12 三月 2025 14:53:08 +0800
Subject: [PATCH] 修改Client封装方式

---
 iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java |   55 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java
index b9cf3fe..651da56 100644
--- a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java
+++ b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java
@@ -1,28 +1,67 @@
 package com.iailab.sdk.auth.config;
 
 import com.iailab.sdk.auth.client.IailabAuthClient;
+import com.iailab.sdk.auth.factory.YamlPropertySourceFactory;
 import com.iailab.sdk.util.http.IailabHttpUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.core.io.ClassPathResource;
 
 import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
 
 
 /**
  * SDK配置文件
  */
 @Configuration
-@EnableConfigurationProperties(AuthProperties.class)
+@PropertySource(
+        value = "classpath:auth.yaml",
+        factory = YamlPropertySourceFactory.class  // 使用自定义加载器
+)
 public class SdkAutoConfiguration {
-    private final AuthProperties authProperties;
+    @Value("${iailab.token.base-url}")
+    private String baseUrl;
 
-    public SdkAutoConfiguration(AuthProperties authProperties) {
-        this.authProperties = authProperties;
-    }
+    @Value("${iailab.token.tenant-id}")
+    public Long tenantId;
+
+    @Value("${iailab.token.client-id}")
+    public String clientId;
+
+    @Value("${iailab.token.client-secret}")
+    public String clientSecret;
+
+    @Value("${iailab.token.username}")
+    public String username;
+
+    @Value("${iailab.token.password}")
+    public String password;
+
+    public static String BASE_URL;
+
+    public static Long TENANT_ID;
+
+    public static String CLIENT_ID;
+
+    public static String CLIENT_SECRET;
+
+    public static String USERNAME;
+
+    public static String PASSWORD;
 
     @PostConstruct
-    public void init() {
-        IailabAuthClient.setAuthProperties(authProperties);
-        IailabHttpUtils.setAuthProperties(authProperties);
+    public void initUrl() {
+        BASE_URL = this.baseUrl;
+        TENANT_ID = this.tenantId;
+        CLIENT_ID = this.clientId;
+        CLIENT_SECRET = this.clientSecret;
+        USERNAME = this.username;
+        PASSWORD = this.password;
     }
 }

--
Gitblit v1.9.3