zhongrj
2023-09-01 30a032b5cc400f28fee28802a6354b8e774ba634
自定义上传配置修改
1 files modified
38 ■■■■■ changed files
skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/builder/oss/OssBuilder.java 38 ●●●●● patch | view | raw | blame | history
skjcmanager/skjcmanager-ops/skjcmanager-resource/src/main/java/cn/gistack/resource/builder/oss/OssBuilder.java
@@ -137,34 +137,20 @@
    public OssTemplate templateByPath(String code,String prefixPath) {
        String tenantId = AuthUtil.getTenantId();
        Oss oss = getOss(tenantId, code);
        Oss ossCached = ossPool.get(tenantId);
        OssTemplate template = templatePool.get(tenantId);
        // 若为空或者不一致,则重新加载
        if (Func.hasEmpty(template, ossCached) || !oss.getEndpoint().equals(ossCached.getEndpoint()) || !oss.getAccessKey().equals(ossCached.getAccessKey())) {
            synchronized (OssBuilder.class) {
                template = templatePool.get(tenantId);
                if (Func.hasEmpty(template, ossCached) || !oss.getEndpoint().equals(ossCached.getEndpoint()) || !oss.getAccessKey().equals(ossCached.getAccessKey())) {
                    OssRule ossRule;
                    // 若采用默认设置则开启多租户模式, 若是用户自定义oss则不开启
                    if (oss.getEndpoint().equals(ossProperties.getEndpoint()) && oss.getAccessKey().equals(ossProperties.getAccessKey()) && ossProperties.getTenantMode()) {
                        ossRule = new MyOssRule(Boolean.TRUE,prefixPath);
                    } else {
                        ossRule = new MyOssRule(Boolean.FALSE,prefixPath);
                    }
                    if (oss.getCategory() == OssEnum.MINIO.getCategory()) {
                        template = MinioOssBuilder.template(oss, ossRule);
                    } else if (oss.getCategory() == OssEnum.QINIU.getCategory()) {
                        template = QiniuOssBuilder.template(oss, ossRule);
                    } else if (oss.getCategory() == OssEnum.ALI.getCategory()) {
                        template = AliOssBuilder.template(oss, ossRule);
                    } else if (oss.getCategory() == OssEnum.TENCENT.getCategory()) {
                        template = TencentOssBuilder.template(oss, ossRule);
                    }
                    templatePool.put(tenantId, template);
                    ossPool.put(tenantId, oss);
                }
            }
        template = templatePool.get(tenantId);
        OssRule ossRule = new MyOssRule(Boolean.TRUE,prefixPath);
        if (oss.getCategory() == OssEnum.MINIO.getCategory()) {
            template = MinioOssBuilder.template(oss, ossRule);
        } else if (oss.getCategory() == OssEnum.QINIU.getCategory()) {
            template = QiniuOssBuilder.template(oss, ossRule);
        } else if (oss.getCategory() == OssEnum.ALI.getCategory()) {
            template = AliOssBuilder.template(oss, ossRule);
        } else if (oss.getCategory() == OssEnum.TENCENT.getCategory()) {
            template = TencentOssBuilder.template(oss, ossRule);
        }
        templatePool.put(tenantId, template);
        ossPool.put(tenantId, oss);
        return template;
    }