yangys
2024-03-28 13ada1093cb8de6e31a718d2222429ded70133c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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);
    }
}