/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.config;

import com.crunii.micro.common.web.exception.GlobalExceptionHandler;
import com.crunii.micro.web.interceptor.CallHolderInterceptor;
import com.crunii.micro.web.mvc.config.ResourceUrlConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 田平 create 2020年1月9日上午9:45:04
 */
@Configuration
public class CoreConfiguration {

	@Bean
	public GlobalExceptionHandler regGlobalExceptionHandler() {
		return new GlobalExceptionHandler();
	}

	@Bean
	public ResourceUrlConfig regResourceUrlConfig() {
		return new ResourceUrlConfig();
	}

	/**
	 * 接口项目可以配置currWorker.enabled=false,取消当前用户拦截，提高效率
	 *
	 * @return
	 */
	@Bean
	@ConditionalOnProperty(name = "currWorker.enabled", havingValue = "true", matchIfMissing = true)
	public CallHolderInterceptor regCallHolderInterceptor() {
		return new CallHolderInterceptor();
	}
}
