|
|
@@ -1,6 +1,7 @@
|
|
|
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;
|
|
|
@@ -11,7 +12,10 @@ import cn.tr.plugin.eventbus.config.EventBus;
|
|
|
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;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -23,6 +27,8 @@ 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;
|
|
|
|
|
|
/**
|
|
|
@@ -32,7 +38,8 @@ import javax.validation.Validator;
|
|
|
* @date 2023/05/09 14:29
|
|
|
**/
|
|
|
@Service
|
|
|
-public class SysStorageConfigServiceImpl implements ISysStorageConfigService {
|
|
|
+@Slf4j
|
|
|
+public class SysStorageConfigServiceImpl implements ISysStorageConfigService, CommandLineRunner {
|
|
|
private final String STORAGE_DEFAULT_TOPIC="/storage/default/refresh";
|
|
|
private final String STORAGE_CONFIG_TOPIC="/storage/config/refresh";
|
|
|
@Autowired
|
|
|
@@ -101,8 +108,7 @@ public class SysStorageConfigServiceImpl implements ISysStorageConfigService {
|
|
|
@Override
|
|
|
public boolean updateSysStorageConfigById(SysStorageConfigDTO source){
|
|
|
SysStorageConfigPO config = SysStorageConfigMapper.INSTANCE.convertPO(source);
|
|
|
- config
|
|
|
- .setConfig(parseClientConfig(config.getType(), source.getConfig()));
|
|
|
+ config.setConfig(parseClientConfig(config.getType(), source.getConfig()));
|
|
|
if (baseRepository.updateById(config)!=0) {
|
|
|
eventBus.publishShare(STORAGE_CONFIG_TOPIC,new Object());
|
|
|
return true;
|
|
|
@@ -126,7 +132,11 @@ public class SysStorageConfigServiceImpl implements ISysStorageConfigService {
|
|
|
.setConfig(parseClientConfig(config.getType(), source.getConfig()))
|
|
|
// 默认非 master
|
|
|
.setMaster(master);
|
|
|
- return baseRepository.insert(config)!=0;
|
|
|
+ if (baseRepository.insert(config)!=0) {
|
|
|
+ eventBus.publishShare(STORAGE_CONFIG_TOPIC,new Object());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -194,4 +204,10 @@ public class SysStorageConfigServiceImpl implements ISysStorageConfigService {
|
|
|
return clientConfig;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void run(String... args) throws Exception {
|
|
|
+ storageUpdate();
|
|
|
+ storageConfigUpdate();
|
|
|
+ log.info("[存储配置]加载完成");
|
|
|
+ }
|
|
|
}
|