潘志宝
2025-03-13 98ed4d3f740409b963f3d853e4300f503a327fd4
iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/config/SdkAutoConfiguration.java
@@ -1,9 +1,9 @@
package com.iailab.sdk.auth.config;
import com.iailab.sdk.auth.client.IailabAuthClient;
import com.iailab.sdk.util.http.IailabHttpUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import com.iailab.sdk.auth.factory.YamlPropertySourceFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import javax.annotation.PostConstruct;
@@ -12,17 +12,48 @@
 * SDK配置文件
 */
@Configuration
@EnableConfigurationProperties(AuthProperties.class)
@PropertySource(
        value = "classpath:application.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;
    }
}