package com.bonus.file.config;

import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.minio.MinioClient;

/**
 * Minio 配置信息
 *
 * @author bonus
 */
@Configuration
//@ConditionalOnProperty(name = "storage.type", havingValue = "minio")
@ConfigurationProperties(prefix = "minio")
@Data
public class MinioConfig
{
    /**
     * 服务地址
     */
    private String endpoint = "http://127.0.0.1:9000";

    /**
     * 用户名
     */
    private String accessKey = "minioadmin";

    /**
     * 密码
     */
    private String secretKey = "minioadmin";

    /**
     * 存储桶名称
     */
    private String bucketName = "bonus-file";

    @Bean
    public MinioClient getMinioClient()
    {
        return MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build();
    }
}
