package com.qianwen.core.excel.extend.config;
|
|
import java.util.ArrayList;
|
import java.util.Collection;
|
import java.util.List;
|
import javax.annotation.PostConstruct;
|
import com.qianwen.core.excel.extend.aop.DynamicNameAspect;
|
import com.qianwen.core.excel.extend.aop.RequestExcelArgumentResolver;
|
import com.qianwen.core.excel.extend.aop.ResponseExcelReturnValueHandler;
|
import com.qianwen.core.excel.extend.processor.NameProcessor;
|
import com.qianwen.core.excel.extend.processor.NameSpelExpressionProcessor;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Import;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
|
@EnableConfigurationProperties({ExcelConfigProperties.class})
|
@Configuration(proxyBeanMethods = false)
|
@Import({ExcelHandlerConfiguration.class})
|
/* loaded from: blade-starter-excel-9.3.0.0-SNAPSHOT.jar:org/springblade/core/excel/extend/config/ResponseExcelAutoConfiguration.class */
|
public class ResponseExcelAutoConfiguration {
|
private final RequestMappingHandlerAdapter requestMappingHandlerAdapter;
|
private final ResponseExcelReturnValueHandler responseExcelReturnValueHandler;
|
static final /* synthetic */ boolean $assertionsDisabled;
|
|
static {
|
$assertionsDisabled = !ResponseExcelAutoConfiguration.class.desiredAssertionStatus();
|
}
|
|
public ResponseExcelAutoConfiguration(final RequestMappingHandlerAdapter requestMappingHandlerAdapter, final ResponseExcelReturnValueHandler responseExcelReturnValueHandler) {
|
this.requestMappingHandlerAdapter = requestMappingHandlerAdapter;
|
this.responseExcelReturnValueHandler = responseExcelReturnValueHandler;
|
}
|
|
@ConditionalOnMissingBean
|
@Bean
|
public NameProcessor nameProcessor() {
|
return new NameSpelExpressionProcessor();
|
}
|
|
@ConditionalOnMissingBean
|
@Bean
|
public DynamicNameAspect dynamicNameAspect(NameProcessor nameProcessor) {
|
return new DynamicNameAspect(nameProcessor);
|
}
|
|
@PostConstruct
|
public void setReturnValueHandlers() {
|
Collection<? extends HandlerMethodReturnValueHandler> returnValueHandlers = this.requestMappingHandlerAdapter.getReturnValueHandlers();
|
List<HandlerMethodReturnValueHandler> newHandlers = new ArrayList<>();
|
newHandlers.add(this.responseExcelReturnValueHandler);
|
if (!$assertionsDisabled && returnValueHandlers == null) {
|
throw new AssertionError();
|
}
|
newHandlers.addAll(returnValueHandlers);
|
this.requestMappingHandlerAdapter.setReturnValueHandlers(newHandlers);
|
}
|
|
@PostConstruct
|
public void setRequestExcelArgumentResolver() {
|
Collection<? extends HandlerMethodArgumentResolver> argumentResolvers = this.requestMappingHandlerAdapter.getArgumentResolvers();
|
List<HandlerMethodArgumentResolver> resolverList = new ArrayList<>();
|
resolverList.add(new RequestExcelArgumentResolver());
|
resolverList.addAll(argumentResolvers);
|
this.requestMappingHandlerAdapter.setArgumentResolvers(resolverList);
|
}
|
}
|