package com.ycwl.basic.storage.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class AwsOssStorageConfig extends StorageConfig {
    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;
    private String bucketName;
    private String url;
    private String region;
    private String prefix;

    @Override
    public void checkEverythingOK() {
        // TODO: 检查配置是否正确
    }

    public String getUrl() {
        String url = this.url;
        if (url == null) {
            url = bucketName + "." + endpoint;
        }
        if (!url.startsWith("http")) {
            url = "https://" + url;
        }
        if (url.endsWith("/")) {
            url = url.substring(0, url.length() - 1);
        }
        return url;
    }
}
