package cn.superdesk.uniorder.config;

import cn.superdesk.uniorder.dto._constant.ResourceConstant;
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 = "excel.export", name = "enabled", havingValue = "true")
public class ResourceConfiguration {

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

    /**
     * initExcelExportConstant
     *
     * @return
     */
    @Bean
    public ResourceConstant resourceConstant() {

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

                .pathRoot(pathRoot)
                .pathTemplate(pathTemplate)
                .pathStorage(pathStorage)

                .build();
    }

}
