package com.ruoyi.web.core.config;

import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author: yjx
 * @date: 2023年09月12日 09:59
 * @Description:
 */
@Data
@Configuration
public class OssConfig {
  @Value("${aliyun.oss.accessKeyId:}")
  private String accessKeyId;

  @Value("${aliyun.oss.accessKeySecret:}")
  private String accessKeySecret;

  @Value("${aliyun.oss.publicBucketName:}")
  private String publicBucketName;

  @Value("${aliyun.oss.endpointUrl:}")
  private String endpointUrl;

  private String domain;

  public String getDomain() {
    if (StringUtils.isEmpty(this.getEndpointUrl())
        || StringUtils.isEmpty(this.getPublicBucketName())) {
      return "";
    }
    return this.getEndpointUrl().replace("https://", "https://" + this.getPublicBucketName() + ".");
  }

}
