多模块重构 5:infra 模块的修改~~~

This commit is contained in:
YunaiV
2022-01-31 17:57:45 +08:00
parent dc11dfc215
commit 9bc9b2ac6b
153 changed files with 1420 additions and 1742 deletions

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Predicate;
@Slf4j
public class DBConfigRepository extends AbstractConfigRepository {
@ -135,7 +136,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
private Properties buildProperties(List<ConfigRespDTO> configs) {
Properties properties = propertiesFactory.getPropertiesInstance();
configs.stream().filter(ConfigRespDTO::getDeleted) // 过滤掉被删除的配置
configs.stream().filter(config -> !config.getDeleted()) // 过滤掉被删除的配置
.forEach(config -> properties.put(config.getKey(), config.getValue()));
return properties;
}

View File

@ -16,7 +16,7 @@ import org.springframework.context.annotation.Configuration;
*/
@Configuration
@MapperScan(value = {"${yudao.info.base-package}", "${yudao.core-service.base-package}",
"${yudao.info.member-package}", "${yudao.info.system-package}"},
"${yudao.info.base-package2}"},
annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
public class YudaoMybatisAutoConfiguration {

View File

@ -36,11 +36,9 @@ public class WebProperties {
private String prefix;
/**
* Controller 所在包
* Controller 所在包的 Ant 路径规则
*
* 主要目的是,给该 Controller 设置指定的 {@link #prefix}
*
* 因为我们有多个 modules 包里会包含 Controller所以只需要写到 cn.iocoder.yudao 这样的层级
*/
@NotEmpty(message = "Controller 所在包不能为空")
private String controller;

View File

@ -13,6 +13,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.cors.CorsConfiguration;
@ -49,8 +50,9 @@ public class YudaoWebAutoConfiguration implements WebMvcConfigurer {
* @param api API 配置
*/
private void configurePathMatch(PathMatchConfigurer configurer, WebProperties.Api api) {
AntPathMatcher antPathMatcher = new AntPathMatcher(".");
configurer.addPathPrefix(api.getPrefix(), clazz -> clazz.isAnnotationPresent(RestController.class)
&& clazz.getPackage().getName().startsWith(api.getController())); // 仅仅匹配 controller 包
&& antPathMatcher.match(api.getController(), clazz.getPackage().getName())); // 仅仅匹配 controller 包
}
@Bean