package cc.smtweb.system.bpm.spring.config;

import cc.smtweb.framework.core.db.jdbc.IdGenerator;
import cc.smtweb.system.bpm.util.FilePathGenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 微服务框架封装自动配置类
 */
@Configuration
public class FileConfig {
    // 文件本地存储配置
    @Value("${smtweb.file.local-path}")
    private String fileLocalPath;

    // 文件请求URL路径配置 http://127.0.0.1:${server.port}/${server.servlet.context-path}/files/
    @Value("${smtweb.file.url}")
    private String fileUrl;

    @Bean
    public FilePathGenerator filePathGenerator(IdGenerator idGenerator) {
        return new FilePathGenerator(fileLocalPath, fileUrl, idGenerator);
    }
}
