package com.gyee.frame.common.conf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ImgConfiguration implements WebMvcConfigurer {
    private static final Logger log = LoggerFactory.getLogger(ImgConfiguration.class);
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        /**
//         * @Description: 对文件的路径进行配置, 创建一个虚拟路径/templates/** ，即只要在<img src="/templates/picName.jpg" />便可以直接引用图片
//         *这是图片的物理路径  "file:/+本地图片的地址"
//         */
//        registry.addResourceHandler("/templates/**").addResourceLocations
//                ("file:/E:/IdeaProjects/gaygserver/src/main/resources/static/");
////        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/static/");
//        super.addResourceHandlers(registry);
//    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        String imgurl=V2Config.imgurl;
        imgurl="file:"+imgurl;
        log.info("**************初始化图片存储路径******************");
        log.info(imgurl);
        log.info("********************************");
        registry.addResourceHandler("/IMGURL/**").addResourceLocations(imgurl);

        String audurl=V2Config.audurl;
        audurl="file:"+audurl;
        log.info("**************初始化音频存储路径******************");
        log.info(audurl);
        log.info("********************************");
        registry.addResourceHandler("/ADUURL/**").addResourceLocations(audurl);

    }
}