cn.herodotus.engine.assistant.autoconfigure.AssistantAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assistant-spring-boot-starter Show documentation
Show all versions of assistant-spring-boot-starter Show documentation
基于 Spring Authorization Server 的 Dante Cloud Assistant 模块统一 Starter
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2020-2030 郑庚伟 ZHENGGENGWEI (码匠君), Licensed under the AGPL License
*
* This file is part of Dante Engine.
*
* Dante Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dante Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package cn.herodotus.engine.assistant.autoconfigure;
import cn.herodotus.engine.assistant.autoconfigure.customizer.StandardErrorCodeMapperBuilderCustomizer;
import cn.herodotus.engine.assistant.definition.function.ErrorCodeMapperBuilderCustomizer;
import cn.herodotus.engine.assistant.definition.domain.ErrorCodeMapper;
import cn.herodotus.engine.assistant.definition.support.ErrorCodeMapperBuilder;
import jakarta.annotation.PostConstruct;
import org.dromara.hutool.extra.spring.SpringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import java.util.List;
/**
* Description: Definition 自动配置
*
* @author : gengwei.zheng
* @date : 2022/1/13 20:00
*/
@AutoConfiguration
@Import({
SpringUtil.class,
})
public class AssistantAutoConfiguration {
private static final Logger log = LoggerFactory.getLogger(AssistantAutoConfiguration.class);
@PostConstruct
public void postConstruct() {
log.info("[Herodotus] |- Module [Assistant Starter] Auto Configure.");
}
@Bean
public ErrorCodeMapperBuilderCustomizer standardErrorCodeMapperBuilderCustomizer() {
StandardErrorCodeMapperBuilderCustomizer customizer = new StandardErrorCodeMapperBuilderCustomizer();
log.debug("[Herodotus] |- Strategy [Standard ErrorCodeMapper Builder Customizer] Auto Configure.");
return customizer;
}
@Bean
public ErrorCodeMapperBuilder errorCodeMapperBuilder(List customizers) {
ErrorCodeMapperBuilder builder = new ErrorCodeMapperBuilder();
customize(builder, customizers);
log.debug("[Herodotus] |- Bean [ErrorCodeMapper Builder] Auto Configure.");
return builder;
}
private void customize(ErrorCodeMapperBuilder builder, List customizers) {
for (ErrorCodeMapperBuilderCustomizer customizer : customizers) {
customizer.customize(builder);
}
}
@Bean
public ErrorCodeMapper errorCodeMapper(ErrorCodeMapperBuilder builder) {
ErrorCodeMapper mapper = builder.build();
log.debug("[Herodotus] |- Bean [ErrorCodeMapper] Auto Configure.");
return mapper;
}
}