package com.moka.gdtauto.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云OSS配置类
 */
@Configuration
@ConfigurationProperties(prefix = "aliyun.oss")
@Data
public class AliyunOssConfig {
    
    /**
     * OSS访问密钥ID
     */
    private String accessKeyId;
    
    /**
     * OSS访问密钥Secret
     */
    private String accessKeySecret;
    
    /**
     * OSS服务端点（本地公网：oss-cn-shanghai.aliyuncs.com，上线私网：oss-cn-shanghai-internal.aliyuncs.com）
     */
    private String endpoint;
    
    /**
     * Bucket名称
     */
    private String bucketName;
    
    /**
     * CDN域名
     */
    private String cdnDomain;
    
    /**
     * 创建OSS客户端Bean
     */
    @Bean
    public OSS ossClient() {
        return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
    }
}
