package {{ .package }}.entrance.web;

import com.vs.debug.stack.config.EnableVSReplayConfiguration;
import com.vs.sqlmapper.spring.DataSourceConfig;
import com.vs.sqlmapper.spring.scan.VSDaoBeanScan;
import com.vs.mock.config.EnableVSMockConfiguration;
import com.vs.sqlmapper.spring.express.EnableVSMockExpress;
import com.vs.agent.TocoAgentInitializer;

import com.vs.debug.stack.agent.LogStackContextInvokeRecorder;
import com.vs.debug.stack.agent.MethodVisitorHandlerFilter;
import com.vs.debug.stack.agent.StackContextInvokeRecorder;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"})
@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"})
@Import(DataSourceConfig.class)
@EnableVSReplayConfiguration
@EnableVSMockConfiguration
@EnableVSMockExpress
@MapperScan("com.codvision.*.mapper")
public class AppApplication{

//    @Bean(name = "stackContextInvokeRecorder")
//    public StackContextInvokeRecorder createStackContextInvokeRecorder() throws Exception {
//        return new LogStackContextInvokeRecorder(); // 可以根据需求扩展实现
//    }

    @Bean
    public MethodVisitorHandlerFilter createMethodVisitorHandlerFilter() {
        StackContextInvokeRecorder stackContextInvokeRecorder = new LogStackContextInvokeRecorder();
        return new MethodVisitorHandlerFilter(stackContextInvokeRecorder);
    }

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(AppApplication.class);
        application.addInitializers(new TocoAgentInitializer());
        application.run(args);
    }
}
