package com.chushang.oss.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.Serial;
import java.io.Serializable;

@Configuration
@ConfigurationProperties(prefix = "oss")
@Data
public class UploadConfig implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
     * 获取 domain 路径, 用于返回完整的请求路径
     */
    private String domain;
    /**
     * 获取临时存储路径, 用于解压缩等
     */
    private String tmpPath;
    /**
     * ali, minio
     */
    private String storage;
    /**
     * minio url ,  阿里云EndPoint
     */
    private String endPoint;
    /**
     * minio accessKey , 阿里云AccessKeyId
     */
    private String accessKey;
    /**
     * minio secretKey, 阿里云AccessKeySecret
     */
    private String secretKey;
    /**
     * 统一前缀
     */
    private String prefix;
    private String bucketName;

    @PostConstruct
    public void init() {
        _domain = domain;
        _tmpPath = tmpPath;
    }

    private static String _domain;
    private static String _tmpPath;

    /**
     * 获取 domain 路径, 用于返回完整的请求路径
     */
    public static String getDomain(){
        return _domain;
    }

    /**
     * 获取临时存储路径, 用于解压缩等
     */
    public static String getTmpPath(){
        return _tmpPath;
    }
}