Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/auto save systremConfig #430

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.mongodb.core.BulkOperations;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
Expand Down Expand Up @@ -182,9 +183,13 @@ public AppContractDto queryDependency(String operationId, String operationType,

@Override
public List<AppContractDto> queryAppContracts(String appId, String operationId) {
Query query = Query.query(
Criteria.where(AppContractCollection.Fields.operationId).is(operationId)
.and(AppContractCollection.Fields.appId).is(appId));
Query query = new Query();
if (StringUtils.isNotBlank(appId)) {
query.addCriteria(Criteria.where(AppContractCollection.Fields.appId).is(appId));
}
if (StringUtils.isNotBlank(operationId)) {
query.addCriteria(Criteria.where(AppContractCollection.Fields.operationId).is(operationId));
}
List<AppContractCollection> daos = mongoTemplate.find(query, AppContractCollection.class);
return daos.stream().map(AppContractMapper.INSTANCE::dtoFromDao).collect(Collectors.toList());
}
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