package cn.superdesk.uniorder.openapi.config.env;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2021/3/2 下午2:02
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/3/2 下午2:02
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Configuration
@ConditionalOnProperty(prefix = "env.output", name = "enabled", havingValue = "true")
public class EnvConfig {

	@Value("${env.output.path.root:/tmp}")
	private String pathRoot;
	@Value("${env.output.path.template:/tmp/template}")
	private String pathTemplate;
	@Value("${env.output.path.storage:/tmp/_storage}")
	private String pathStorage;

	/**
	 * initEnvOutputConstant
	 *
	 * @return
	 */
	@Bean
	public EnvOutputConstant envOutputConstant() {

		log.info("\n初始化 ExcelExport Init :\n{}\n{}\n{}\n\n", pathRoot, pathTemplate, pathStorage);
		return EnvOutputConstant.builder()
				.pathRoot(pathRoot)
				.pathTemplate(pathTemplate)
				.pathStorage(pathStorage)
				.build();
	}

}
