18339543638 %!s(int64=2) %!d(string=hai) anos
pai
achega
3885b0345c

+ 8 - 4
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/storage/service/impl/StorageFileServiceImpl.java

@@ -79,13 +79,17 @@ public class StorageFileServiceImpl implements IStorageFileService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public SysStorageRecordDTO upload(String configId,String cateId,String filename, byte[] content) throws Exception {
-        SysStorageConfigDTO config=defaultConfig;
-        if(StrUtil.isNotEmpty(configId)){
-            config=storageConfigService.selectSysStorageConfigById(configId);
+        if(StrUtil.isEmpty(configId)){
+            configId=defaultConfig.getId();
         }
+//        SysStorageConfigDTO config=defaultConfig;
+//        if(StrUtil.isNotEmpty(configId)){
+//            config=storageConfigService.selectSysStorageConfigById(configId);
+//        }
+        FileClient fileClient = fileClientFactory.getFileClient(configId);
         String bizName = createBizName(filename);
         String suffix = FileUtil.extName(filename);
-        FileClient fileClient = getClient(config);
+//        FileClient fileClient = getClient(config);
         fileClient.upload(content,bizName);
         String downUrl = fileClient.downUrl(bizName);
         SysStorageRecordDTO record = SysStorageRecordDTO.builder()

+ 0 - 4
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/storage/service/impl/SysStorageConfigServiceImpl.java

@@ -1,7 +1,6 @@
 package cn.tr.module.sys.storage.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
-import cn.hutool.extra.spring.SpringUtil;
 import cn.tr.core.exception.ServiceException;
 import cn.tr.core.exception.TRExcCode;
 import cn.tr.core.utils.JsonUtils;
@@ -13,7 +12,6 @@ import cn.tr.plugin.file.config.FileClientConfig;
 import cn.tr.plugin.file.enums.FileStorageEnum;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import lombok.extern.slf4j.Slf4j;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.context.annotation.Lazy;
@@ -27,8 +25,6 @@ import cn.tr.module.sys.storage.dto.SysStorageConfigQueryDTO;
 import java.util.*;
 import cn.tr.module.sys.storage.service.ISysStorageConfigService;
 import cn.tr.module.sys.storage.mapper.SysStorageConfigMapper;
-
-import javax.annotation.PostConstruct;
 import javax.validation.Validator;
 
 /**

+ 3 - 7
tr-plugins/tr-spring-boot-starter-plugin-file/src/main/java/cn/tr/plugin/file/config/LocalFileClientFactory.java

@@ -29,13 +29,9 @@ public class LocalFileClientFactory implements FileClientFactory{
     @Override
     public <Config extends FileClientConfig> FileClient createOrUpdateFileClient(String configId, String storage, Config config) {
         AbstractFileClient<Config> client = (AbstractFileClient<Config>) clients.get(configId);
-        if (client == null) {
-            client = this.createFileClient(configId, storage, config);
-            client.init();
-            clients.put(client.getId(), client);
-        } else {
-            client.refresh(config);
-        }
+        client = this.createFileClient(configId, storage, config);
+        client.init();
+        clients.put(client.getId(), client);
         return client;
     }