Skip to content

Commit

Permalink
feat: auto save systemConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
wildeslam committed Jul 4, 2024
1 parent 3fba525 commit bfd2749
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.arextest.common.cache.CacheProvider;
import com.arextest.config.repository.impl.SystemConfigurationRepositoryImpl;
import com.arextest.web.core.business.ConfigLoadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -28,4 +29,13 @@ public OldDataCleaner oldDataCleaner(CacheProvider cacheProvider,
return new OldDataCleaner(cacheProvider, mongoTemplate, redisLeaseTime, systemConfigurationRepository);
}

@Lazy(false)
@Bean
@ConditionalOnMissingBean(name = "systemConfigBootstrap")
public SystemConfigBootstrap systemConfigBootstrap(
ConfigLoadService configLoadService,
SystemConfigurationRepositoryImpl systemConfigurationRepository) {
return new SystemConfigBootstrap(configLoadService, systemConfigurationRepository);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.arextest.web.api.service.beans;

import com.arextest.config.model.dao.config.SystemConfigurationCollection.KeySummary;
import com.arextest.config.model.dto.system.SystemConfiguration;
import com.arextest.config.repository.SystemConfigurationRepository;
import com.arextest.web.core.business.ConfigLoadService;
import java.util.HashSet;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;

/**
* @author wildeslam.
* @create 2024/7/3 16:15
*/
@Data
@Slf4j
@AllArgsConstructor
public class SystemConfigBootstrap implements InitializingBean {

private ConfigLoadService configLoadService;
private SystemConfigurationRepository systemConfigurationRepository;


@Override
public void afterPropertiesSet() {
Set<String> ignoreNodeSet = configLoadService.getIgnoreNodeSet("");
if (ignoreNodeSet == null) {
ignoreNodeSet = new HashSet<>();
}
SystemConfiguration systemConfiguration = new SystemConfiguration();
systemConfiguration.setKey(KeySummary.IGNORE_NODE_SET);
systemConfiguration.setIgnoreNodeSet(ignoreNodeSet);
systemConfigurationRepository.saveConfig(systemConfiguration);
}


}

This file was deleted.

2 changes: 1 addition & 1 deletion arex-web-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
profiles:
active: prod
active: dev
application:
name: Arex web service
jackson:
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@

<properties>
<!-- Maven CI Friendly Versions https://maven.apache.org/maven-ci-friendly.html -->
<revision>0.6.5</revision>
<revision>0.6.5.1</revision>
<arex-common.version>0.1.28</arex-common.version>
<arex-extension-interface.version>0.0.1</arex-extension-interface.version>
<arex-storage-config.version>1.2.7</arex-storage-config.version>
<arex-storage-config.version>1.2.15</arex-storage-config.version>
<arex-storage.version>1.1.27</arex-storage.version>
<arex-compare-extension.version>0.0.1</arex-compare-extension.version>
<caffeine.version>2.9.3</caffeine.version>
Expand Down

0 comments on commit bfd2749

Please sign in to comment.