package com.trade.service.filestorage.config;

import com.trade.common.config.TradeConfig;
import com.trade.common.constant.Constants;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.trade.service.filestorage.util.FileUtil;

import javax.annotation.Resource;

/**
 * 系统自定义相关配置
 */
@Configuration
public class CustomConfiguration implements WebMvcConfigurer {

    @Resource
       private TradeConfig tradeConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/" + FileUtil.DIR + "/**")
                .addResourceLocations("file:" + FileUtil.getAbsoluteDir() + "/" + FileUtil.DIR + "/");
        registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
                .addResourceLocations("file:" + tradeConfig.getProfile() + "/");
    }
}
