From cd510b43b1ef85202ddf9018271aaadf695f3c8d Mon Sep 17 00:00:00 2001 From: hewenqiang <1527468660@qq.com> Date: 星期二, 25 一月 2022 17:17:06 +0800 Subject: [PATCH] fix 优化登录、注册校验方式,在接口通过@Validated进行数据基础校验,以及服务执行到异常后,抛出异常结束方法执行(减少if-else嵌套)。 --- ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuOssStrategy.java | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuOssStrategy.java b/ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuOssStrategy.java index 23c6648..417f703 100644 --- a/ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuOssStrategy.java +++ b/ruoyi-oss/src/main/java/com/ruoyi/oss/service/impl/QiniuOssStrategy.java @@ -10,8 +10,11 @@ import com.ruoyi.oss.entity.UploadResult; import com.ruoyi.oss.enumd.OssEnumd; import com.ruoyi.oss.exception.OssException; +import com.ruoyi.oss.factory.OssFactory; import com.ruoyi.oss.properties.OssProperties; import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; import java.io.InputStream; @@ -20,15 +23,17 @@ * * @author Lion Li */ +@Component public class QiniuOssStrategy extends AbstractOssStrategy { private UploadManager uploadManager; private BucketManager bucketManager; private Auth auth; + @Override - public void init(OssProperties cloudStorageProperties) { - properties = cloudStorageProperties; + public void init(OssProperties ossProperties) { + super.init(ossProperties); try { Configuration config = new Configuration(getRegion(properties.getRegion())); // https璁剧疆 @@ -36,15 +41,12 @@ config.useHttpsDomains = "Y".equals(properties.getIsHttps()); uploadManager = new UploadManager(config); auth = Auth.create(properties.getAccessKey(), properties.getSecretKey()); - String bucketName = properties.getBucketName(); bucketManager = new BucketManager(auth, config); - - if (!ArrayUtil.contains(bucketManager.buckets(), bucketName)) { - bucketManager.createBucket(bucketName, properties.getRegion()); - } + createBucket(); } catch (Exception e) { throw new OssException("涓冪墰浜戝瓨鍌ㄩ厤缃敊璇�! 璇锋鏌ョ郴缁熼厤缃�:[" + e.getMessage() + "]"); } + isInit = true; } @Override @@ -61,8 +63,8 @@ } @Override - public String getServiceType() { - return OssEnumd.QINIU.getValue(); + public OssEnumd getServiceType() { + return OssEnumd.QINIU; } @Override -- Gitblit v1.9.3