package cn.com.capcloud.core.system.configuration;

import cn.com.capcloud.core.util.MinioUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinIOConfig {
    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(MinioUtils.class);
    @Value("${rzth.minio.endpoint:http://127.0.0.1:9000}")
    private  String endpoint;
    @Value("${rzth.minio.bucketName:}")
    private String bucketName;
    @Value("${rzth.minio.accessKey:}")
    private  String accessKey;
    @Value("${rzth.minio.secretKey:}")
    private  String secretKey;
    @Value("${rzth.minio.isCreateMinIOConnect:N}")
    private  String isCreateMinIOConnect;

    @Bean
    public MinioUtils creatMinioClient() {
        if(isCreateMinIOConnect.equals("Y")){
            logger.info("启用MinIO配置");
            return new MinioUtils(endpoint, bucketName, accessKey, secretKey);
        }else{
            logger.info("不启用MinIO配置");
            return null;
        }
    }

}
